On 07/19/2012 08:36 PM, Osemeka Osuagwu wrote: > <snip>... > 99 ninety nine > 100 onehundred > 101 one hundred and one > 102 one hundred and two > 103 one hundred and three > 104 one hundred and four > 105 one hundred and five > 106 one hundred and six > 107 one hundred and seven > 108 > > Traceback (most recent call last): > File "C:/Windows.old/Users/Abasiemeka/Abasiemeka/GOOGLE > University/Python/Python Code/MyCode/Project Euler code/Project Euler > answer 17.py", line 33, in <module> > print i, num2word(i) > File "C:/Windows.old/Users/Abasiemeka/Abasiemeka/GOOGLE > University/Python/Python Code/MyCode/Project Euler code/Project Euler > answer 17.py", line 18, in num2word > wordlist = [units[eval(str(num)[-3])-1],'hundred', 'and', > num2word(eval(str(num)[-2:]))] > File "<string>", line 1 > 08 > ^ > SyntaxError: invalid token >
08 isn't a valid literal. Remove the leading zero. That says that the following digits are to be interpreted as octal, and 8 isn't a valid octal digit. Much better would be to eliminate the unnecessary use of eval(). It's dangerous, and sometimes doesn't do what you expect. -- DaveA _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
