Making a string out of a string and an integer in Python

Posted by Waterfox on Stack Overflow See other posts from Stack Overflow or by Waterfox
Published on 2010-05-12T22:27:57Z Indexed on 2010/05/12 22:34 UTC
Read the original article Hit count: 274

Filed under:
|
|
|
|

I get this error when trying to take an integer and prepend "b" to it, converting it into a string:

  File "program.py", line 19, in getname
    name = "b" + num
TypeError: Can't convert 'int' object to str implicitly

That's related to this function:

num = random.randint(1,25)
name = "b" + num

© Stack Overflow or respective owner

Related posts about python

Related posts about python-3.x