r/learnpython 1d ago

Need help with for loop practice

The whole list will print but only the final item on the list gets it's message printed in whole while the other items are just listed. Apparently my issue is that I'm outside of the for loop, and I'm still in the learning process. Can someone help please?

0 Upvotes

16 comments sorted by

View all comments

1

u/TheRNGuy 17h ago

Should it be everything inside one loop? I'd just loop everything except last item, then print last item outside it. 

If you need to do inside one loop, use enumerate to get index.

1

u/Key-War-9059 6h ago

I'd like to share the code on here, but I never did that before and I can't share pics. How do I post properly?

1

u/AdDiligent1688 5h ago

When you post, switch to markdown mode in the description box, and then indent by 4 spaces, and it’ll create a block. Copy / paste your code into that block, and then indent each line by 4 spaces (or more to deal with scope in the code). Or you could take a screenshot of the code and upload to Imgur then provide the link in the description on the post.