Q:

Write a Python program to change a given string to a new string where the first and last chars have been exchanged.

0

Write a Python program to change a given string to a new string where the first and last chars have been exchanged. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def change_sring(str1):
      return str1[-1:] + str1[1:-1] + str1[:1]
	  
print(change_sring('abcd'))
print(change_sring('12345'))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now