+ 1

You're given a program that outputs all the numbers from 0 to 10. Change the code to make it output only the even numbers.

HELP!! My mind is all over the place

17th Feb 2022, 11:44 AM
pain fr
pain fr - avatar
5 Antworten
+ 3
An even number is the one which when divided by 2 gives a remainder 0.
17th Feb 2022, 12:05 PM
Avinesh
Avinesh - avatar
+ 3
pain fr , can you please post your code, so that we can see where the issue is? thanks!
17th Feb 2022, 5:55 PM
Lothar
Lothar - avatar
0
Brian I get that but how can I make it so that only the even numbers print and not the odd numbers
18th Feb 2022, 9:49 AM
pain fr
pain fr - avatar
0
Lothar Brian Avinesh Thank you for helping!! My smol brain figured it out
18th Feb 2022, 9:57 AM
pain fr
pain fr - avatar
- 1
Look at the example given in Python Lesson 23.1. Consider how you could modify it to do what you want. Here is the code: x = 1 while x < 10: if x%2 == 0: print(str(x) + " is even") else: print(str(x) + " is odd") x += 1
17th Feb 2022, 6:29 PM
Brian
Brian - avatar