-2

I'm having issues replacing a "?" with a zero. What ogtL is just a list of numbers that I've taken from an excel file. From that excel is just more numbers.I'm just having problems as to why its not working and I would also like some help on putting the new string back into ogtL.

for eachWord in ogtL: #ogtL is a List
    newString=""
    for eachCharacter in eachWord:
        newString+=eachCharacter
        newString.replace("?","0")
    print(newString)
Mell0w
  • 47
  • 7

1 Answers1

3

i think the problem is you're not saving the output of your replace to a variable.

for eachWord in ogtL: #ogtL is a List
    newString=""
    for eachCharacter in eachWord:
        newString+=eachCharacter
        newString = newString.replace("?","0")
    print(newString)

You also don't need to iterate of each character like that, I think you can do this:

for eachWord in ogtL: #ogtL is a List
    newString=eachWord.replace("?","0")        
    print(newString)
Tucker
  • 7,017
  • 9
  • 37
  • 55