-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_new_country.py
36 lines (27 loc) · 964 Bytes
/
get_new_country.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
This module contains the function to get the name of a country from the user
and validate it
Parameters:
None
Returns:
country (str): The name of a country
"""
def get_new_country():
"""
Function to get the name of a country from the user
and validate it
"""
bad_chars = ('?', '!', '/', '\\', '@', '#', '$', '%', '^', '&', '*',
'(', ')', '_', '+', '=', '~', '`', '[', ']', '{', '}',
'|', '<', '>', ',', '.', ';', ':', '"')
while True:
country = input("Enter the full name country of the city: ")
good_name = True
for letter in country:
if letter in bad_chars:
print('City names can not contain characters such as: "/", "?" or "!"')
good_name = False
break
if good_name:
break
return country