Notification keeps popping up on my Pythonista iPad app: name ‘test’ is not defined.
-
Hi I am a serious beginner with python and pythonista and I a stuck pretty early on in my course. What does this notification mean? Name ‘test’ is not defined.
Here is the code:
print("fill out this form") print("enter your name") name = input() print("how old are you?") age = input() print("do you want to be an email suscriber?") yes_no = input() test(input())
-
In some cases, errors mean just what they say.
What do you expect the line
test(input)
to do, and how would Python know that is what you intend?
test
is not a standard Python function, so if you are using it, YOU must define it, usingdef
.
-
Oh, I thought test is a standard python function, so I was googling if I maybe had the wrong version of the Pythonista app downloaded. I had the same issue with type(). Is that also not a standard python function?
The task that I am trying to accomplish with the above code is to:
- Create a variable to store input: name, age, yes_no
- Create prompts for name, age and yes/no to being on an email list
- Print a description + variable values for each variable
-
@hi_christina not very nice but to give you an idea
print("fill out this form") name = input("enter your name") age = input("how old are you?") yes_no = input("do you want to be an email suscriber?") print('name =',name) print('age =',age) print('email=',yes_no)
-
Here was the other example with the type() command:
I input 54 as the input value.—————
print("enter a name or number")
test_input = input()
type(test_input)
———————————-
This appeared in the console:enter a name or number
54
I tried this and nothing appeared in the console.
test_input = “Lala”
type(test_input)
-
@hi_christina type is a valid Python function but not for printing. It gives the type of the object
-
@hi_christina you can get local help of each function by selecting the word, then...
-
When I use the type() function on jupyter, there is no problem. I get str back when I run the cell. But in pythonista I do not get anything back when I run this.
print("enter name")
name = input()
type(name)
-
@hi_christina see my previous posts. If you want to see the result of type,
print(type(name))
-
Oh man!!! 😅Thank you! 🙏
I understand what you mean now about type being a valid Python function but not for printing. Sorry, I didn’t understand before, but it all makes sense now!! Thanks for helping out!
-
@hi_christina welcome here and good luck
-
This post is deleted!last edited by
-
This post is deleted!last edited by