Simple method with just return keyword returns a None
def abc():
return
print(abc())
Output: None
Similarly,
def abc():
return None
print(abc())
Output: None
However if we use this in generator
def abc():
yield 1
return None
print(abc())
it gives
SyntaxError: 'return' with argument inside generator
where as
def abc():
yield 1
return
print(abc())
gives
<generator object abc at 0x7f97d7052b40>
Why do we have this difference in behavior?