entremanure entremanure - 10 days ago 6
Python Question

Python: Adding characters to strings error

I am creating a pseudo random encryption program, and IDLE returns and error when I try to expand my seed value. The code goes like this.

for i in str(addon):
seed = str(seed)
seed.append(str(i))
seed = int(seed)


When I run it, this happens.

AttributeError: 'str' object has no attribute 'append'


Any ideas on how I can add characters onto the end of a string?

Answer

Use + instead of append. Append is for list objects.

seed += str(i)