+ 1
Def function in python
Just learned about using DEF and I’m doing some tests, with the following input: Def user_info(): Age = input(“what’s your age?”) Name = input(“what’s your name?) Print(user_info) And it’s working fine i just wanna know why by the end of the outputs I’m getting a “none” printed as well.
6 Antworten
+ 5
You need to add return statement.
+ 5
def user_info():
age = input("what's your age? ")
name = input("what's your name? ")
return name, age
print(user_info())
+ 4
By the way thanks to that topic I realized that code playground for python doesn't work when there are 2 inputs.
+ 3
It does, sort of. You have to enter both inputs at the same time, e. g.
69 [hit 'enter']
David [hit 'submit'] 😁
+ 1
because by default, each function returns a None.
+ 1
Hubert Dudek can you give me an example?