What will this program display? Help urgently! Python experts.
word = "keyboard"
result = ''
for sign in word:
result = sign + result
print(result)
Answers
Answered by
1
Pretty small answer but hope this helps you ♥
Attachments:
Answered by
0
Code :
word = "keyboard"
result = ''
for sign in word:
result = sign + result
print(result)
Output :
draobyek
Explanation :
The above code is for reversing the given string.
This statement : for sign in word: Loop through the letters in the word
This statement : result = sign + result is used for concatenation of the strings.
- result = k + " = k
- result = e + k = ek
- result = y + ek = yek
- result = b + yek = byek
- result = o + byek = obyek
- result = a + obyek = aobyek
- result = r + aobyek = raobyek
- result = d + raobyek = draobyek
So, final output is draobyek.
Attachments:
Similar questions