Begginer here! I'm starting to learn how to code, and I've encountered an issue...
I created a basic "Maximum number" function, and then took user inputs as the three parameters in the function, but for some reason it's not returning the desired value.
def max_num(num1, num2, num3):
if num1 >= num2 and num1 >= num3:
return num1
elif num2 >= num1 and num2 >= num3:
return num2
else:
return num3
user1 = input("Enter a number --> ")
user2 = input("Enter another number --> ")
user3 = input("Enter one last number --> ")
print("The larger of those numbers is: " + max_num(user1, user2, user3))
After typing the values [user1 = 50], [user2 = 150] and [user3 = 100] as the user, and expecting the function to return [150] as the highest value, this is what I get:
Enter a number --> 50
Enter another number --> 150
Enter one last number --> 100
The larger of those numbers is: 50
Process finished with exit code 0
I tried changing the variables' names in case there was some kind of namespace overlapping, without success.
Also noticed that this happens when the values entered by the user have different sizes (one value has 2 digits while the other two have three digits).
Any ideas on how to solve this? Thank you!!