Answer to Question #257338 in Python for Ale

Question #257338

Don't you find it amazing to discover words and sentences that have the same first and last letter? We just don't usually notice them, so we can try it out by coding out this problem instead! Print out "Yes" if the first and last characters of the given string are the same, and "No" otherwise. It doesn't matter if they're in lowercase or uppercase, as long as it's the same letter, it fits the description.

So, what are you waiting for? Code now!


Input

A line containing a string.


Pop·it·up

Output

A line containing a string.


Yes
1
Expert's answer
2021-10-27T03:49:05-0400
#Get string from the User and lower all the characters
string = input("Enter a string: ").lower()


#Check if the string has enough character to compare
#Check if the first character and the last character are the same
if len(string) < 2:
  print("Not enough character to compare")
elif string[0] == string[-1]:
  print("Yes")
else:
  print("No")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS