so I'm trying to append a string of chars to a list, while changing the last char in the list as the loop proceeds. However, whenever I try to change the list of chars, all the previous chars become the new char. My code:
string = list("xxx");
for x_ in range(0, 10):
print string
string[2] = x_;
lisMonthData.append(string);
I'm trying to get the last character in the 2nd position to count up. So for example, I want an output of xx0,xx1,xx2,...,xx9.
Instead, I get an output of xx9,xx9,xx9.....
Is there any more effecient way of creating a three char string while increasing the last digit?
Aucun commentaire:
Enregistrer un commentaire