[Tutor] Changing a string number to another number

Ken G. beachkidken at gmail.com
Wed Apr 15 14:21:33 CEST 2015


When running the following code, I get the following
error code:

201504110102030405061
Traceback (most recent call last):
   File "Mega_Millions_Tickets_Change.py", line 11, in <module>
     datecode[20:21] = "0"
TypeError: 'str' object does not support item assignment


datecode = "201504110102030405061"
print datecode
if datecode[20:21] == "1":
     datecode[20:21] = "0"
print datecode


I have tried using the zero as an integer but still get the same error code.
Any suggestion?

Thanks in advance,

Ken


More information about the Tutor mailing list