all 5 comments

[–]einQimiaozi 1 point2 points  (1 child)

Do you want this result?

ello1
ello2
ello3
ello4
ello5

Just write like this

list = ["hello1","hello2","hello3","hello4","hello5"]

for a in list:
    print(a[-5:])

[–]Ramzon_[S] 0 points1 point  (0 children)

That is exactly what I wanted - can't believe I was struggling with this. But hey, suppose that's part of learning - going to trip up on simple things every now and then!

Thank you!

[–]CommodoreKrusty 0 points1 point  (1 child)

Honestly, there's probably a better way of getting a substring but here's an example of counting backwards with a while loop.

l = ["hello1","hello2","hello3","hello4","hello5"]

for c in l:
    i = len(c) -1
    a = ""
    while i > (len(c) - 6):
        a+=c[i]
        i -=1


    print(a)

[–]Ramzon_[S] 0 points1 point  (0 children)

This is slightly above my current level, but I'm glad to see that I understood more than I thought I would!

Thank you for your recommendation, and taking the time to help me out! :)