I have too many if statements and I have a hard time understanding the dictionary system.
It seems like an easy fix, but everything I try I make it worse.
"""
Find the place where the person was born.
Possible locations are following: Kuressaare, Tartu, Tallinn, Kohtla-Järve, Narva, Pärnu,
Paide, Rakvere, Valga, Viljandi, Võru and undefined. Lastly if the number is incorrect the function must return
the following 'Wrong input!'
:param birth_number: int
:return: str
"""
return
if not is_valid_birth_number(birth_number):
return "Wrong input!"
if 10 >= birth_number >= 1:
return "Kuressaare"
elif 20 >= birth_number >= 11:
return "Tartu"
elif 220 >= birth_number >= 21:
return "Tallinn"
elif 270 >= birth_number >= 221:
return "Kohtla-Järve"
elif 370 >= birth_number >= 271:
return "Tartu"
elif 420 >= birth_number >= 371:
return "Narva"
elif 470 >= birth_number >= 421:
return "Pärnu"
elif 490 >= birth_number >= 471:
return "Tallinn"
elif 520 >= birth_number >= 491:
return "Paide"
elif 570 >= birth_number >= 521:
return "Rakvere"
elif 600 >= birth_number >= 571:
return "Valga"
elif 650 >= birth_number >= 601:
return "Viljandi"
elif 710 >= birth_number >= 651:
return "Võru"
elif 999 >= birth_number >= 711:
return "undefined"
Need to get rid of idcode.py:149:1: C901 'get_birth_place' is too complex (16)
error.
Aucun commentaire:
Enregistrer un commentaire