How to return multiple values from function in python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How to return multiple values from function in python (/thread-1729.html) |
How to return multiple values from function in python - pikkip - Jan-23-2017 def abc(x, y): print x print y x = x + 1 y = y + 1 x = 0 y = 1 x, y = abc(x,y)When I execute this error, I got this error: TypeError: 'NoneType' object is not iterable. What is the reason for this? RE: How to return multiple values from function in python - Mekire - Jan-23-2017 Your function does not modify the global x and y. You need to return the values. def abc(x, y): x += 1 y += 1 return x, y x = 0 y = 1 print("Before: {} {}".format(x, y)) x, y = abc(x,y) print("After: {} {}".format(x, y)) RE: How to return multiple values from function in python - pikkip - Jan-23-2017 Thank you |