Input a string then display it's first and last character in Pythan
on
Get link
Facebook
X
Pinterest
Email
Other Apps
Solution:
str=input(" Enter a String : ") new_str=str[-1:] + str[1:-1] + str[:1] print(new_str)
OR
s=input("Enter a word:") print("The word is ",s) print("The 1st character is",s[0]) print("The last character is",s[len(s)-1]) print("The last character is",s[-1])
Comments
Post a Comment