So I'm confused on how prompt is being "extracted" from the get_int function to the main function once ran. is "x" a global variable that is connecting the two functions?
Code:
def main():
x = get_int("Assign a value to x: ")
print(f"x is {x}")
def get_int(prompt):
while True:
try:
x = int(input(prompt))
except ValueError: # if the user gives a unsupported input
print("The assigned value of x is not a number. ")
else: # if there is no Value error and continue with line 23
break
return x
main()