Files
jps/python/function_2.py
2020-02-25 14:07:10 -06:00

17 lines
433 B
Python

# 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))