Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8
There are a few errors. You define a function but don't call it. It's not always a good idea to use the "while True", especially if you don't close the while loop. You'll have a loop go one forever. def main(): while True: password = input() if password == "Beans": print("Hi") #need to close your loop else: print('get away!') main() Also, remember that Sololearn only accepts input once, after you hit the run button. If you want to test multiple inputs, they need to be on separate lines like this: Hi Password Wrong Beans
7th Jun 2023, 11:58 AM
Ausgrindtube
Ausgrindtube - avatar
+ 8
Stacy Krygier , there are some more issues, not real errors, but should be avoided though: > function names should be followed *directly* by parentesis like *print()*, do not put a space there. > we should not use multiple statements in on line. better to do this: if something == my_value: print(this_message) else: print(that_message) > we should use 4 spaces per indentation level. this improves the readability. >> the main issue is that you most likely haven't gone through a python tutorial. i would recommend you to start with *introduction to python*
7th Jun 2023, 1:59 PM
Lothar
Lothar - avatar
+ 4
Also, in addition to those larger problems: * Beans is currently an undefined variable name, you probably wanted "Beans" with quotation marks instead * Conversely, for input("") the quotation marks don't do anything; arguments passed to input() are just printed as a user prompt, so here you're telling the computer to print an empty string * Password (which contains the user input) is not the same as password (which you compare to Beans). Pay attention to capitalization. The convention, though not a requirement, is to use lower case for regular variables like this, and to reserve capitalized variable names for class names, which is why the playground color-codes those to blue
7th Jun 2023, 1:39 PM
Orin Cook
Orin Cook - avatar
+ 1
It's working Stacy. I'd consider the following updates. password = input() if password == "Beans": print("Hi") break
14th Jun 2023, 11:26 AM
Ausgrindtube
Ausgrindtube - avatar