Files
jps/python/function_2.py

17 lines
433 B
Python
Raw Permalink Normal View History

2020-02-25 11:28:37 -06:00
# A SIMPLE FUNCTION - decides whether a text string starts with a given prefix
def starts_with(string, substring):
if string.startswith(substring):
return True
else:
return False
prefix = 'King'
word = 'Kingdom'
print(word, starts_with(word, prefix))
word = 'Kingston'
print(word, starts_with(word, prefix))
word = 'Kindred'
print(word, starts_with(word, prefix))
word = 'Kingpin'
print(word, starts_with(word, prefix))