-2

Python Newbie here!

def x():
 print ('y')

x()

This produces the output- 'y'

BUT

def x():
 print ('y')
a = x()
print (a)

This produces 'y' and 'None' at the end. Why the none at the end?

idjaw
  • 25,487
  • 7
  • 64
  • 83

1 Answers1

1

This is because the function x () is returning nothing, hence None.

return 'y' to get print of 'a'.

Hope this helps.

Harv
  • 446
  • 5
  • 12