Hi, @arwaahmed ,
It is important to format code when you post it. That enables users to see your indentation and other important details.
See How do I format code in my posts?.
You have chosen to begin with an empty string, which you assign to
result, here ...
result = ""
... and then to accumulate the data there.
append method can be called from
lists, but not from
strings, therefore this is invalid ...
Having committed to use a
string as an accumulator, you should use concatenation, instead, to accumulate the characters.
Also, since you are iterating through indexes, using
i, here ...
for i in range(len(words)):
... you must use that index,
i, to access individual characters in the string that is referenced by
words. You are attempting to append the index,
i, directly to
Modifying your statement to use indexes and concatenation, you can do this ...
result = result + words[i]
... or this ...
result += words[i]