On 04/13/2015 08:18 AM, Dave Angel wrote:
On 04/13/2015 08:11 AM, Ken G. wrote:
I am sure there is an simple explanation but when I input
5 (as integer), resulting in 05 (as string), I get zero as the end
result. When running the code:
START OF PROGRAM:
Enter the 1st number: 5
05
0
END OF PROGRAM:
START OF CODE:
import sys
def numberentry():
print
number01 = raw_input("Enter the 1st number: ")
if number01 == "0":
sys.exit()
if len(number01) == 1:
number01 = "0" + number01
print
print number01
return(number01)
number01 = 0
What is this line intended to do?
NameError: name 'number01' is not defined
numberentry()
Where are you intending to store the return value? Currently, you're
just throwing it away.
I am not sending anything to the def routine but expected an answer in
return.
print
print number01
This variable has no relation to the one in the function. In fact,
I'd recommend you use a different name, to make that clear.
Do not use return at end of routine? I am lost there.
END OF CODE:
Thanks for answering.
Ken
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor