Creating a code

Hello guys, I have difficulties generating a code for this question.

Input two positive integers x and y. Assume y is bigger than x.
Prints the even numbers between x and y (inclusive)

Print the word “End” before the program ends.

what I did was to create this code but it doesn’t work. Appreciate if someone can help me.

x=input(int("Enter x: "))
y=input(int("Enter y: "))

for i in range(x,y+1):
if i % 2==0:
print(f"{i} is Even")
print(“End”)

You need to pass the return from the input() function (which is a string) to the int() function to do the type conversion: x = int(input("Enter x: "))

Once you corrected that, you should be good to go.

Thank you for the help Rob, much appreciated

1 Like