Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Pythonista is telling my input is not defined
-
I just started learning to code and wanted to do more when I'm not on my laptop so downloaded Pythonista. I made this script and when I compiled it I get an error stating that my input is not defined. How can you define your input?
Here is the code:
coding: utf-8
name = input("what is your name? ")
age = int(input("what is your age?"))if (age >= 18) and (age < 90):
print("You can vape {}" .format(name))
if age > 90:
print("{} vaping is not recommended" .format(name))
else:
print("wait {} years" .format(18 - age)) -
@ducky908 , your code is ok as far as I can tell, it's just the indentation.
The below works, only difference is the code is indented correctly
name = input("what is your name? ") age = int(input("what is your age?")) if (age >= 18) and (age < 90): print("You can vape {}" .format(name)) if age > 90: print("{} vaping is not recommended" .format(name)) else: print("wait {} years" .format(18 - age))
-
@ducky908 , sorry. I was running python 3.5x, I guess you are running python 2.7.x
But for 2.7x the below works. It's using raw_input
coding: utf-8 try: raw_input input = raw_input # Python 2 except NameError: # Python 3 pass name = input("What is your name? ").strip() age = int(input("What is your age? ")) if 18 <= age < 90: print("You can vape {}." .format(name)) if age >= 90: print("{} vaping is not recommended." .format(name)) else: print("Wait {} years." .format(18 - age))
-
@Phuket2 I downloaded Pythonista 3 and everything works now.