I can't put an integer on the string, so what should I do?
TypeError: unsupported operand type(s) for +: 'int' and 'str'
for i in range (1,10):
string="string"+i
Cannot perform +
operation because the two are of different types. Therefore, instead of an integer i
, str(i)
should be a string.
Last result, string is
for i in range (1,10):
string="string"+str(i)
string = []
for i in range(1,10):
string.append("string"+str(i))
#or
string = ["string"+str(i) for i in range(1,10)]
© 2025 OneMinuteCode. All rights reserved.