Forum Archive

Notification keeps popping up on my Pythonista iPad app: name ‘test’ is not defined.

hi_christina

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())
JonB

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, using def.

hi_christina

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:
1. Create a variable to store input: name, age, yes_no
2. Create prompts for name, age and yes/no to being on an email list
3. Print a description + variable values for each variable

cvp

@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) 
hi_christina

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)

cvp

@hi_christina type is a valid Python function but not for printing. It gives the type of the object

cvp

@hi_christina you can get local help of each function by selecting the word, then...

hi_christina

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)

cvp

@hi_christina see my previous posts. If you want to see the result of type,

print(type(name)) 
hi_christina

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!

cvp

@hi_christina welcome here and good luck

philphs

yeah it is use full.small business funding

philphs

yeah it is use full.small business loans startup