Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

Python unindent does not match any outer indentation level problem

fh1

Active Coder
hello! I searched up what the error means but i still cant fix it. if anyone can help, please tell me
 
Solution
I don't get any errors. Note: You should not name a list using a python builtin.





I rewrote your code a little.


Python:
from string import ascii_letters as letters, digits
from random import sample, shuffle
from time import sleep
import sys
characters = list(letters + digits)
shuffle(characters)

genpass = ''.join(sample(characters, k=5))
print(f'Your generated password is {genpass}')
password = input('Enter password:\n>> ')
if password == genpass:
    play = input('Enter p to play\n>> ').lower()
else:
    print('Wrong password! Goodbye!')
    sys.exit()
if play == 'p':
    print('Welcome to my game')
    sleep(2)
    print('Proffesor Dogwater: Oh hello Alex !(you) Could you help me find this...
hello! I searched up what the error means but i still cant fix it. if anyone can help, please tell me
Hi there,

I have a feeling that it may be due to something in your code not being properly indented. Can you post your code so we can see where that may be?
 
Python:
import random
import time
number = random.randint(1,100)
print(number)
list = ["h", "hello", "bro", "mbappe", "fjkrehfehfa", "mat", "oilmanu"]
mypasswordstring = (random.choice(list))
print(mypasswordstring)
mypassword = str(number) + mypasswordstring
print(f"your generated password is: {number}{mypasswordstring}")
typepassword = input("type in your pasword ")
if typepassword == mypassword:
    print("right password!")
    playgame = input("click P to play adventures of the world")
if playgame == 'P' or playgame == 'p':
    print("Welcome to Adventures of the world. in this game you will be adventuring around the globe to find a potion to end all fantasy monsters")
    beginning = input("Proffesor Dogwater: Oh hello Alex !(you) Could you help me find this potion? You'll need to travel almost around the whole world though! I'll reward you with 1M dollars if you find it. type Y to accept the mission. Type N to decline the mission.")
    if beginning == 'Y' or beginning == 'y':
        print("You: Sure! I'll help! Proffesor Dogwater: Oh thank you Alex!")
        print("the proffesor gives you a map to find the potion. it says its in a ancient land hidden in caves from reality called Kall Mon")
        print("You now depart from the town")
        print("30 minutes later...")
time.sleep(2)
option1 = input("you have arrived at a dangerous path featuring a mountain. type 1 to look for another path. type 2 to continue on the dangerous path")
error is on line 21
 
I don't get any errors. Note: You should not name a list using a python builtin.





I rewrote your code a little.


Python:
from string import ascii_letters as letters, digits
from random import sample, shuffle
from time import sleep
import sys
characters = list(letters + digits)
shuffle(characters)

genpass = ''.join(sample(characters, k=5))
print(f'Your generated password is {genpass}')
password = input('Enter password:\n>> ')
if password == genpass:
    play = input('Enter p to play\n>> ').lower()
else:
    print('Wrong password! Goodbye!')
    sys.exit()
if play == 'p':
    print('Welcome to my game')
    sleep(2)
    print('Proffesor Dogwater: Oh hello Alex !(you) Could you help me find this potion? You\'ll need to travel almost around the whole world though! I\'ll reward you with 1M dollars if you find it. type Y to accept the mission. Type N to decline the mission.')
else:
    print('Goodbye!')
    sys.exit()
start = input('>> ').lower()
if start == 'y':
    print("You: Sure! I'll help! Proffesor Dogwater: Oh thank you Alex!")
    print("the proffesor gives you a map to find the potion. it says its in a ancient land hidden in caves from reality called Kall Mon")
    print("You now depart from the town")
    print("30 minutes later...")
    sleep(2)
else:
    print('Goodbye!')
    sys.exit()
print("you have arrived at a dangerous path featuring a mountain. type 1 to look for another path. type 2 to continue on the dangerous path")
option = input('>> ').lower()
 
Last edited:
Solution
You could have mixed space and tabs for indents. Everything will look lined up but it will give you an indent error when you run the code. So one line you did the indent with the tab button and the next line down you use the spacebar will give you an error.
 
Back
Top Bottom