I am a total beginner to python and coding. I Was just wondering if there is a way for python to read what I've typed into the console, For example: If it prints out a question, I can answer with many choices. This is what I've tried yet.
`answer = input("Vilken?")
if answer.lower().strip() == "1":
print("Okej! (1)")
elif answer.lower().strip() == "2":
print("Okej! (2)")
elif answer.lower().strip() == "3":
print("Okej! (3)")`
I got the code from a guy on youtube, for some reason, it doesn't read what I'm typing in.
I am trying to store what the player types on a variable, so I can later use it. In c# I used
string (variable name) = Console.Readline()
If there is a way to do this is python, please let me know.
this will solve your issue:
answer = raw_input("Vilken?")
if answer.lower().strip() == "1":
print("Okej! (1)")
elif answer.lower().strip() == "2":
print("Okej! (2)")
elif answer.lower().strip() == "3":
print("Okej! (3)")
change input to raw_input
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With