I've recently been creating a text adventure game but almost immediately ran into a problem with the input. It is giving me error messages when I use strings instead of integers. There is probably an obvious reason that this is happening and I'm just not seeing it.
Here's an example:
b = input("Do you like video games? y/n")
if b == "y":
print("Good For You!")
if b == "n":
print("What!? (Just joking)")
I've researched a lot and this seems to be working for most other people. But when I use it I get this error:
Do you like video games? y/ny
Traceback (most recent call last):
File "/home/ubuntu/workspace/Test.py", line 1, in <module>
b = input("Do you like video games? y/n")
File "<string>", line 1, in <module>
NameError: name 'y' is not defined
As you can see, it says that y is not defined. I'm okay with basic python programming, but I'm horrible at reading error messages. It would be great if you guys could give me an answer. Thank you!
python3 Test.pyto run it from terminal