Forum Archive

string slicing

SteppenwolfUA

Hi all!

I get an error in Pythonista, but not in Idle on desktop

S = 'abcedfghijklm'
print S[5:1:−1]

What seems to be the problem here?

omz

I'm not getting an error here, it prints fedc, as expected. What kind of error do you get?

ccc

Your -1 has a dash character instead of a minus sign character. If you change it to a minus sign then the world will become a better place.

SteppenwolfUA

@ccc Thanx a lot. I must have copied it from somewhere unexpecting a dash instead of a minus. Well, lesson learned. The traps lurking behind an innocent facade...