Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics Functions and Looping While Loops

My console isn't responding the way it should

password = input("Please input enter the super secret password: ") while password != 'opensesame': password = input("Invalid password, try again:") print("Welcome to a secret town")

I had typed this code into the console when I first typed in an invalid password. However, unlike in the video where is said welcome to a secret town It just kept on saying invalid password try again when I typed in opensesame in the console multiple times

Could you format your code with the Markdown Cheatsheet https://teamtreehouse.com/community/cheatsheet It could be a problem with the indenting but I can't tell in this format.

The above code, but formatted ?

password = input("Please input enter the super secret password: ") 

while password != 'opensesame': 
    password = input("Invalid password, try again:") 

print("Welcome to a secret town")

asking too late !!! have you solved this problem

2 Answers

i think i know the answer. You are running python instead of python3, which is the newest version. If you run python, you have to use raw_input instead of input, or else it will only work if your password is in quotation marks, as such 'opensesame'. Try running python3, just type python3 instead of python. If that doesnt work, change your code to this:

password = raw_input("Please input enter the super secret password: ")

while password != 'opensesame': password = raw_input("Invalid password, try again:")

print("Welcome to a secret town")

Running on Linux, and this worked for me. Thanks for the answer!

cem günaltay
cem günaltay
1,332 Points

Having the same problem as like esmar. Can't fix it anyway. Somebody to help?? Console repeats and locks saying "Please try again" I don't have problem when password is true