The list is to be replaced by names, but for now we need to use ID numbers that use zeros in the beginning. This is the issue in our code currently, seems we need a string integer correspondence that just isn't working out, any help would be greatly appreciated!
list = ['01001000', '01100101', '01111001']
for i in range(len(list)):
if list[i] == '01001000'
list[i] = '800000842'
print(list)
CodePudding user response:
If you want to replace str values to integers use this:
# Note: don't use reserved words to variable name in python
# reserved words : https://www.tutorialspoint.com/What-are-Reserved-Keywords-in-Python
mylist = ['01001000', '01100101', '01111001']
for i in range(len(mylist)):
mylist[i] = int(mylist[i]) # this makes the change
print(mylist)