create an input saying count to a certain number and count every number which is an even numbers in python

You can use a for loop and conditional statement to count up to a certain number and count every even number during the iteration.

main.py
num = int(input("Count to: "))
count = 0

for i in range(1, num+1):
    if i % 2 == 0:
        count += 1
    print(i)

print("Total even numbers counted: ", count)
165 chars
10 lines

In this code, we first take input from the user for the number to count up to. We initialize a count variable to 0, which we will increment every time we encounter an even number during the loop.

We use a for loop and range() function to iterate from 1 up to the input number (num). During each iteration of the loop, we use a conditional statement (if i % 2 == 0) to check if the current number is even. If it is, we increment the count variable. We also use a print() statement to output the current number.

Finally, after the loop is complete, we use another print() statement to output the total number of even numbers that were counted.

gistlibby LogSnag