function returning a list

beliavsky@aol.com beliavsky at 127.0.0.1
Wed Sep 1 14:12:14 EDT 2004


Brad Tilley <bradtilley at usa.net> wrote:
>Can a function return a list?

Yes, it can return anything. Here is a trivial example:

def twice(x):
    return 2*x

print twice(1.0)   # 2.0
print twice([1.0]) # [1.0, 1.0]

Note that "2*x" has a very different effect, depending on what "x" is.



----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---



More information about the Python-list mailing list