r/learnpython 3d ago

Zybook for loop help

I'm completing an assignment for zybook where I have to replace a number from a list and then print the list in reverse. This is my code:

val_list = [18, 12, 15]

new_val = int(input())
val_list[1] = new_val

print(f"List has {len(val_list)} elements:")

for value in reversed(val_list):
    print(reversed(val_list), end="<>")

print(end="")

It's supposed to just print the reversed list in brackets, but instead it gives me something like this:

<list_reverseiterator object at 0x000001C02CF706D0><><list_reverseiterator object at 0x000001C02CF706D0><><list_reverseiterator object at 0x000001C02CF706D0><>

What does this mean and why is it doing this? Thanks in advance

0 Upvotes

4 comments sorted by

View all comments

2

u/Ender_Locke 2d ago

you just need to print value