© Irv Kalb 2016

Irv Kalb, Learn to Program with Python, 10.1007/978-1-4842-2172-3_8

8. Strings

Irv Kalb

(1)Mountain View, California, USA

We started using strings in Chapter 1 with this statement:

print 'Hello World'

Later, we talked about how you get input from the user as a string, and how to convert that input into a number:

>>>>>> age = raw_input('Please enter your age: ')Please enter your age: 24>>> age = int(age)>>>

Then I showed you how to concatenate strings, like this:

>>>>>> string1 = 'Hello'>>> string2 = 'there'>>> greeting = string1 + ' ' + string2>>> print greetingHello there>>>

Other than being used to nicely format output, we haven’t talked that much about strings. In this chapter, and in the next two chapters, we get heavily into strings. ...

Get Learn to Program with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.