String Format Error.

Paulo Repreza pxrepreza at
Tue Dec 23 07:19:21 CET 2008


I'm a newbie with python and I recently bought Beginning with Python (Which
is a book I recommend) but the problem that I'm facing it's the following:

*This is the code:
# Filename:

age = 25
name = 'foobar'

print('{0} is {1} years old'.format(name, age))
print('Why is {0} playing with that python?'.format(name))

*But when I run the script I receive this error:

*Traceback (most recent call last):
  File "", line 7, in <module>
    print('{0} is {1} years old'.format(name, age))
AttributeError: 'str' object has no attribute 'format'

It is an error because of the version that I'm using ? Python 2.5.2 (Debian

Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list