Question #257473

Let us now try comparing two numbers by letting the user input two different numbers and say "Greater" if the first inputted number is greater than the second one, and "Lesser" if it’s the other way around.

Let's go!


Input

A line containing two different numbers separated by a space.

1.2·1.02

Output

A line containing a string.

Greater

Expert's answer

#Get input from the User
numbers = input("Enter the numbers: ")

#Split the input into array of strings
splitted = numbers.split()

#Check if the input values are correct to compare 
iflen(splitted) > 2:
​print("Entered more values than expected")
elif ​len(splitted) < 2: ​print("Not enough values to compare")
else: ​
#Convert string to float ​number1 = float(splitted[0]) ​number2 = float(splitted[1])
#Compare if the number1 is greater/lesser than number2 ​if number1 > number2: ​print("Greater") ​else: ​print("Lesser
LATEST TUTORIALS
APPROVED BY CLIENTS