Python syntax error.....not sure why?

A forum for general discussion of the Python programming language.

Python syntax error.....not sure why?

Postby datus » Mon Jul 08, 2013 4:41 pm

For input 1,000,000 in python shell 3.3.2 i got (1, 0, 0) as an output and i got the point that python interprets 1,000,000 as comma-separated sequence of integers.

But for 6,09 i got syntax error. Why it is so?
datus
 
Posts: 6
Joined: Mon Jul 08, 2013 4:37 pm

Re: Python syntax error.....not sure why?

Postby stranac » Mon Jul 08, 2013 5:10 pm

That's because starting a number with 0 in python means it's an octal number.
9 does not exist in octal.

Also, you should always paste the entire error traceback python gives you.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1144
Joined: Thu Feb 07, 2013 3:42 pm

Re: Python syntax error.....not sure why?

Postby metulburr » Mon Jul 08, 2013 5:57 pm

For input 1,000,000 in python shell 3.3.2 i got (1, 0, 0) as an output and i got the point that python interprets 1,000,000 as comma-separated sequence of integers.

otherwise known as a tuple
Code: Select all
>>> a = 1,000,000
>>> a
(1, 0, 0)
>>> type(a)
<class 'tuple'>
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1469
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 2 guests