Robotics & Artificial Intelligence
What would be the output of following program?
str2 = "My classmate is Aayan"
if str2.endswith("Aayan"):
print("Aayan is studying in class X")
else:
print("Aayan is not the student of class X")
Python String Manipulation
1 Like
Answer
Output
Aayan is studying in class X
Explanation
The endswith() function returns True if the string ends with a particular suffix. Since the string "My classmate is Aayan" ends with "Aayan", the condition becomes true and the first print() statement is executed.
Answered By
3 Likes
Related Questions
Create your portfolio, which should include your name, parent's name, class and address using strings in Python.
What would be the output of following program?
print("Hello\nWorld!") print("Python\tProgramming")What should be the output of following program?
information = "My favorite subject is Python, I want to develop an AI application in Python" val = information.find('T') print(val) if val > 1: print("Python is a good programming language for AI applications ") else: print("My favorite subject is Python")Only single quotes can be used to declare a string in Python.