Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Basic utility functions
7. The startswith() and endswith() functions
Basic manipulation functions
Replacing and splitting
Summary

Instruction

Well done! There are two more useful functions that return True or Falsestartswith() and endswith():

user_input = input('Tell me, how would you introduce yourself if you were to give a lecture? ')
if user_input.startswith('So'):
  print('It\'s not a good habit to start sentences with the word "so"!')

In the code above, we check if the user's input starts with the word 'So'. If it does, we recommend not doing it. The endswith() function works in a similar way.

Exercise

Given a list of European countries, print only those whose names begin with 'S'. Make sure each country is on a new line in the same order as in european_countries.

Stuck? Here's a hint!

Iterate over the list. For each element, check if

element.startswith('S')