71.0k views
1 vote
Assume the variable s references a string. Write an if-else statement that assigns True to the status variable if s ends with "ism". Otherwise, assign False to status.

1 Answer

3 votes

Final answer:

To check if a string ends with a specific sequence of characters, use the endswith() method in Python.

Step-by-step explanation:

To check if a string ends with a specific sequence of characters, we can use the endswith() method in Python. In this case, we want to check if the string s ends with 'ism'.

Here is an example of an if-else statement that assigns True to the status variable if s.endswith('ism') is true. Otherwise, it assigns False to status:

if s.endswith('ism'):
status = True
else:
status = False

This statement checks if the condition s.endswith('ism') is true. If it is, it assigns True to status; otherwise, it assigns False.

User Abhishek Dot Py
by
8.8k points