Python Program to find the largest of three characters using nested if


In this program, You will learn how to find the largest of three characters using nested if statement in Python.


A b B => b

A B C => C

Example: How to find the largest of three characters using nested if in Python

x = input("Enter first character:")
y = input("Enter second character:")
z = input("Enter third character:")

if x > y:
    if x > z:
        print("Greatest is:", x)
    else:
        print("Greatest is:", z)
else:
    if y > z:
        print("Greatest is:", y)
    else:
        print("Greatest is:", z)

Output:

Enter first character:a
Enter second character:c
Enter third character:b
Greatest is: c