+ 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 Answers
+ 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?