def camp():
final_campus = input("Enter campus are you enrolled to: Cape Town, Johannesburg, Durban, or Phokeng")
while final_campus!="Johannesburg" or "Cape Town" or "Durban" or "Phokeng":
print("Please enter a valid campus: either 'Johannesburg', 'Cape Town', 'Durban', or 'Phokeng'")
break
else:
return final_campus
Asked
Active
Viewed 26 times
0

Thabo Thandekiso
- 13
- 4
-
you should prefer using Enum and asking only number from user not typing full words – Drako Jun 09 '22 at 09:54
-
make a List with all name and use `if final_campus not in *list*: --your code-- ` Also as @Drako said it would be best to do a dict for example with ids and name! If you want to check the input you just use dict.values() – Almos Jun 09 '22 at 09:54
-
def camp(): camps=("Johannesburg", "Cape Town", "Durban", "Phokeng") while True: final_campus = input("fc: ") if final_campus in camps: return final_campus – Drako Jun 09 '22 at 09:58