1

I'm trying to reverse letters in a string, so mathematics would become 'scitamehtam'.

    word = input("Enter a word: ")
    steps = 0
    while steps < (len(word)):
        index = -1
        count = 1
        newword=word[index] = word[count]
        steps = steps + 1
        index = index - 1
        count = count + 1
    print(newword) 

I get an error saying 'str' object does not support item assignment. How do I change a string without getting this error.

BVB44
  • 106
  • 1
  • 8
  • 3
    Does this answer your question? [Changing one character in a string](https://stackoverflow.com/questions/1228299/changing-one-character-in-a-string) – Woodford May 19 '21 at 16:27

0 Answers0