Rename function_2 to function_2.py
This commit is contained in:
16
python/function_2.py
Normal file
16
python/function_2.py
Normal 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))
|
||||
Reference in New Issue
Block a user