I implemented the finger exercise from chapter 2.4 of the book called Intro to Computation Programming using PythonIntro to Computation Programming using Python by John Guttag.
The task is:
Write a program that asks the user to input 10 integers, and then prints the largest odd number that was entered. If no odd number was entered, it should print a message to that effect.
Is the code without any holes? How can I not make myself repeatavoid repeating the same line, 10 times? Thanks
a = int(input('Enter the number: '))
b = int(input('Enter the number: '))
c = int(input('Enter the number: '))
d = int(input('Enter the number: '))
e = int(input('Enter the number: '))
f = int(input('Enter the number: '))
g = int(input('Enter the number: '))
h = int(input('Enter the number: '))
i = int(input('Enter the number: '))
j = int(input('Enter the number: '))
A = [a,b,c,d,e,f,g,h,i,j]
A.sort()
while True:
if A[len(A)-2]<A[len(A)-1]:
if A[len(A)-1]%2==1:
break
A[len(A)-2]=A[(len(A)-2)-1]
A[len(A)-1]=A[(len(A)-1)-1]
print(A[len(A)-1],'is the largest odd')