Python - WAP to Print the Largest Odd or Even Number of a List in Python - 17
This is a Python Code to Print the Largest Odd or Even Number of a List in Python.
Source Code:
#!/usr/bin/python3
while True:
    num = int(input("Enter the total Number of Elements : "))
    tot = []
    for idx in range(1, num+1):
        a = int(input("Enter %d Element : " % (idx)))
        tot.append(a)
    even = []
    odd = []
    for jdx in tot:
        if ( jdx % 2 == 0 ):
            even.append(jdx)
        else:
            odd.append(jdx)
    even.sort()
    odd.sort()
    count1 = 0
    count2 = 0
    for kdx in even:
        count1 += 1
    for rdx in odd:
        count2 += 1
    print ("Largest Even Number : ", even[count1-1])
    print ("Largest Odd Number : ", odd[count2-1])
    
    if (input(" To Continue 'y' : ") == 'y'):
        continue
    else:
        break
Program Output:

...

Post a Comment