wrobl...@cmich.edu wrote:
Thank you for the reply.. I tried putting the print repr(n)
before I defined 'n' with raw_input. My script looks like
this------
def divisible(n):
if n%3 == 0:
print n, "is divisible by 3"
else:
print n, "is not divisible by 3"
n= raw_input("enter a number= ")
print repr(n)
print divisible(n)
I don't understand what the problem is
The problem is raw_input gives you a string. So in your example n is a
string and when it comes to n%3 python tries to format your string, but
since you haven't any formating symbols in it, it fails.
To fix your program, convert the n to int:
divisible(int(n))
- Patrick
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor