- 1

What's the output of this code? list = [2, 3, 4, 5, 6, 7] for x in list: if(x%2==1 and x>4): print(x) break

Could anyone help me explain why the answer is 5 Am a beginner and i really want to understand it very well

27th Dec 2021, 5:35 PM
Opaal Henry
Opaal Henry - avatar
3 Answers
+ 1
Opaal Henry do the python course. The code you posted is fundamental programming knowledge
27th Dec 2021, 8:45 PM
John Doe
0
The only case in which the condition of if statement is correct when x = 5 where 5%2=1 and 5>4 ... So the code will print 5 and break the loop ... follow me to help you in your problems
27th Dec 2021, 5:56 PM
Shafiq Almatari
Shafiq Almatari - avatar
0
Please fo the following things when posting a question: 1. Tag the language 2. Write it as code (not plain text)
27th Dec 2021, 8:44 PM
John Doe