+ 1
I want to make a program in Python which takes 10 integer values from user and prints the largest odd integer. Plz help.
I know to use if, elif, else, while and print and I want to make the program using these commands only.
12 ответов
+ 3
An alternative with a combination of while loop and if..else blocks
loop, i = 0, 1
max_odd = None
while loop < 10:
n = int(input("Input number #" + str(i) + ": "))
print(n)
if n % 2 != 0:
if max_odd is None:
max_odd = n
else:
if n > max_odd:
max_odd = n
loop += 1
i += 1
print(f"\nLargest odd number is {max_odd}")
+ 2
Firstly you could use a loop to get 10 values from a user and put them into a list:
Then divide every number by 2 to find the odd numbers, remove the even numbers from the list.
Then do a bunch of comparisons using if statements to find the largest one
If you need example code just give me a shout
+ 1
Numbers = []
For a in range(10):
num = int(input(""))
Numbers.append(num)
+ 1
Check on my profile I have posted the working code for that section
+ 1
Also I would recommend programming this in python Idle instead of on sololearn
0
how to put the values in a list?
0
It shows syntax error for 'a' in line 2.
0
Em make your code public and I can take a look
0
I havent written the code yet because I couldnt figure out how can i make a program like this. Can you write this one for me as I dont know how to make this program plz?
0
ok I will check.
Thanks
0
There Sam ^^