Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Apr 15th, 2005, 6:00 PM   #1
acab
Newbie
 
Join Date: Apr 2005
Posts: 7
Rep Power: 0 acab is on a distinguished road
Newbie quesiton: variable assigment

In the Python Shell:
newnum = num % 2
works fine, but when used in a super simple script it get an error:

newnumb = num % 2
TypeError: not all arguments converted during string formatting

print "This program checks to see if a number is prime, "
num = raw_input("Choose a number: ")
newnumb = num % 2
if newnumb != 0:
    print "The number ", num, " is not a prime. "
else:
    print "Congrats! The number ", num, " is a prime. "

Just learnign Python, thanks in advance
acab
acab is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC