Description: Write a function task_4_1 which takes no parameters. When called, prompt the user for an input with the string "Please enter your matriculation number:." First remove leading and trailing whitespaces. Then check if the input is an integer using the built-in functionality. If the input is not a number, then output the following: "Invalid input. Not a number…" If the input is a valid integer but is greater than (or equal to) 12000000, output the following: "Invalid input. Not a valid matriculation number…" Repeat asking the user to enter their matriculation number using the prompt above. Once the user input a valid number, your function should return it (converted to an actual integer)
My Problem is "If the input is a valid integer but is greater than (or equal to) 12000000, Output..." it's not working the way I wrote this condition, it creates an error that says "'>=' not supported between instances of 'str' and 'int'" and I dont know how to make it work the right way..
import string
def task_4_1():
num = input("Please enter your matriculation number: ")
if(num.isdigit()):
return(int(num.strip()))
elif num>=12000000:
print("Invalid input. Not a valid matriculation number...")
num = input("Please enter your matriculation number: ")
else:
print("Invalid input. Not a valid matriculation number...")