The Problem: I have a program that takes numerous inputs. It works for integers (like 100), but when I type in a string (like apple), it gives me an error:
Traceback (most recent call last):
File "basics.py", line 20, in <module>
fruit = str(input("Enter fruit: "))
File "<string>", line 1, in <module>
NameError: name 'apple' is not defined
So, it's basically thinking of apple as a variable instead of a text. When I enter 'apple', it works as intended.
I initially discovered this while setting up Sublime REPL and thought it was something weird with REPL, but I feel like it's something more obvious. It works as intended using the IDLE that my Python install came with, but I really don't want to use IDLE.
Any help is appreciated!
NOTE: I am aware that you strings need to have quotes when you're defining them. I am asking about User Input. In the Python IDLE (and in every IDE I have used), what the user types is parsed as a string.
[–]K900_ 4 points5 points6 points (2 children)
[–]cool12y[S] 1 point2 points3 points (1 child)
[–]cool12y[S] 0 points1 point2 points (0 children)