input(): “NameError: name ‘n’ is not defined” [duplicate]
Use raw_input in Python 2 to get a string, input in Python 2 is equivalent to eval(raw_input). >>> type(raw_input()) 23 <type ‘str’> >>> type(input()) 12 <type ‘int’> So, When you enter something like n in input it thinks that you’re looking for a variable named n: >>> input() n Traceback (most recent call last): File … Read more