why is none written at the end? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why is none written at the end?

def spam(x): """this is a doc string""" if x==10: print("x is 10") print(spam.__doc__) print(spam(10))

27th Jan 2022, 11:16 AM
NIKHIL
2 Answers
+ 1
In the last line of the function, write return ("x is 10") instead of print ("x is 10")
27th Jan 2022, 12:52 PM
𝑨𝒍𝒗𝒊𝒏
𝑨𝒍𝒗𝒊𝒏 - avatar
0
You don't returning anything from function and trying to print returned value.. Just use spam(10)
27th Jan 2022, 11:22 AM
Jayakrishna 🇮🇳