+ 7
[Solved] Why coming None in output with ASCII values?
I am printing the ASCII values of alphabets but I also am also getting None? Does anyone know the reason? See the Code below def printAscii(): str = "abcdefghijklmnopqrstuvwxyz" for i in str: #print(i, end = ' ') print(ord(i), end = ' ') print(printAscii())
10 ответов
+ 10
because youre printing a function that prints. and the function doesnt return anything, so it prints None after it takes care of the call to print out all of the ascii values.
instead of
print(print_ASCII())
just
print_ASCII()
+ 5
DAC 🎯 [Exams] TheWh¡teCat 🇧🇬 $hardul B ♤♢☞ 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 ☜♢♤ Slick Namit Jain
Thanks to all. I didn't notice that I am printing function also but Java doesn't gives output like in python.
+ 4
AJ #L1G3 I'm not that into Python but i found something similar
https://stackoverflow.com/questions/28812851/why-is-this-printing-none-in-the-output
+ 4
DAC 🎯 [Exams] I did that purposefully!
print("hello world")
Will give only hello world
But
print(print("hello world"))
Will give hello world None
+ 3
+ 3
DAC 🎯 [Exams] , because there are two print statements => one in the function and the other outside when calling the function. So when the function finishes the last thing it does is print inside a print, but print return None and the outside print shows that result.