Python 2.7.6 help with white spaces?

Chris Angelico rosuav at gmail.com
Fri Feb 7 06:06:49 CET 2014


On Fri, Feb 7, 2014 at 4:01 PM, Scott W Dunning <swdunning at cox.net> wrote:
> Oops, thought you said turning a str into an int.  Yeah, I’m actually using Idle on a mac.  I keep trying differnt things but, I’m just very new to this.
>
> Is this what you’re talking about?
>
> minutes=3
> seconds=11
>
> print str(minutes) + ‘:’ + str(seconds)
>
> Unfortunately I keep getting an error.  Also, not really clear on the reasoning behind changing the int to a string?

Here's another fundamental of Python: Error messages are really REALLY
useful. In this case, I can figure out what's going on without seeing
it, but normally, post the whole traceback. The problem here is
because you're using "smart quotes" of some sort. Use ordinary
apostrophes and double quotes, and it'll work fine.

As to the reason for changing the int to a string... try skipping it!
Then you'll know. You'll get a nice tidy error, pointing you to the
exact cause of the problem.

>>> print minutes + ':' + seconds

See what happens!

ChrisA



More information about the Python-list mailing list