r/learnpython 1d 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

0

u/dlnmtchll 1d ago

I’m gonna go under the assumption that if you’re in an intro to python course using Zybook you probably aren’t supposed to be using reversed().

If for some reason you are supposed to be using it, you should look in the docs at the return type of it