Rename function_2 to function_2.py

This commit is contained in:
Joe James
2020-02-25 14:07:10 -06:00
committed by GitHub
parent 0002b7f7d0
commit 512996d68b

16
python/function_2.py Normal file
View File

@@ -0,0 +1,16 @@
# 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))