+ 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.

25th Oct 2018, 8:47 AM
Sam Thakkar
Sam Thakkar - avatar
12 odpowiedzi
+ 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}")
25th Oct 2018, 3:04 PM
Ipang
+ 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
25th Oct 2018, 8:56 AM
PureLogicality
PureLogicality - avatar
25th Oct 2018, 10:04 AM
PureLogicality
PureLogicality - avatar
+ 1
Numbers = [] For a in range(10): num = int(input("")) Numbers.append(num)
25th Oct 2018, 8:59 AM
PureLogicality
PureLogicality - avatar
+ 1
Check on my profile I have posted the working code for that section
25th Oct 2018, 9:10 AM
PureLogicality
PureLogicality - avatar
+ 1
Also I would recommend programming this in python Idle instead of on sololearn
25th Oct 2018, 9:14 AM
PureLogicality
PureLogicality - avatar
0
how to put the values in a list?
25th Oct 2018, 8:57 AM
Sam Thakkar
Sam Thakkar - avatar
0
It shows syntax error for 'a' in line 2.
25th Oct 2018, 9:03 AM
Sam Thakkar
Sam Thakkar - avatar
0
Em make your code public and I can take a look
25th Oct 2018, 9:03 AM
PureLogicality
PureLogicality - avatar
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?
25th Oct 2018, 9:07 AM
Sam Thakkar
Sam Thakkar - avatar
0
ok I will check. Thanks
25th Oct 2018, 9:15 AM
Sam Thakkar
Sam Thakkar - avatar
0
There Sam ^^
25th Oct 2018, 10:04 AM
PureLogicality
PureLogicality - avatar