Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65591

Re: Python 2.7.6 help with white spaces?

References <DC365E9C-9511-49BD-A53F-67B4ED3A561F@cox.net> <504A0CAE-42E4-495E-96AA-C8A45559E139@cox.net>
Date 2014-02-07 15:45 +1100
Subject Re: Python 2.7.6 help with white spaces?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.6479.1391748358.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Feb 7, 2014 at 3:09 PM, Scott W Dunning <swdunning@cox.net> wrote:
> Is this what you’re talking about?
>
> minutes = “3”
> seconds = “11”
>
> print int(minutes), ”:" int(seconds)
>
> That’s what you mean by turning a string into an int right?  Not sure how to add strings together though.
>

Well, that's what I would have meant, if I'd talked about turning a
string into an int :) Now, can you do the opposite? Turn an int into a
string? It's done in very much the same way.

Adding strings together is done in the same way as adding integers,
lists, or anything else:

>>> 'foo' + 'bar'
'foobar'

And remember this, whatever else you do: The interactive interpreter
is your friend. Keep it handy. On Windows, you'll find IDLE in your
Start menu - it's awesome for this sort of thing. On Linux, you might
need to explicitly install IDLE. Either way, you can also just type
"python" at the command line, and you'll get something that lets you
type stuff in and see the result, like I showed above; it's called a
Read-Evaluate-Print Loop, or REPL.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Python 2.7.6 help with white spaces? Chris Angelico <rosuav@gmail.com> - 2014-02-07 15:45 +1100

csiph-web