User Profile
Collapse
-
Thank you! Yes, this is clearer to me now. So no return statement means that no value is returned (after reading elsewhere a little I found this means it returns a value of None). Anything more than 1 variable being returned results in a list being returned. As well, I didn't know that no return and a return without a variable are the exact same thing.... -
return keyword
In a Python function definition, sometimes you don't see the return keyword at all. Sometimes, you see it all by itself. And sometimes, you see it associated with a bunch of variables - like "return x, y, z".
Can someone clearly explain the differences between these 3 scenarios? What exactly is happening? What is the Python keyword "return" for? -
dshimer, jlm699, and bvdet - thanks to you all for responding. That was very helpful and educational!Leave a comment:
-
-
Python. So here is some code...
num = raw_input("Pick a number: ")
num = int(num)
print "Your number times 5 is", num * 5, "."
This produces a space between num and the period. If I try to use "+" I get an error trying to concatenate a str and int. It's possible to print str(num) and then concatenate that result with the period to eliminate the space. But I was wondering...Leave a comment:
-
Concatenation
After getting raw_input from the user, I want to print a sentence that ends in an integer and then the "." character. Of course, if I print using a comma (,) I don't get an error but there is an ugly space between the integer and the period. But if I try "+" then I obviously get a str/int concatenation error.
One way to solve this is to convert the int into a str and then "+" works. But is there an easier...
No activity results to display
Show More
Leave a comment: