Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 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 Respostas
+ 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?