+ 1
Can someone tell why this happens? (Check the code below)
3 Answers
+ 9
Hey!
I can help you with this (the others I didn't even understand đ
)
Like in your example:
print(Strange_happening[::-1])
This reverse a string. Like "HOME" becomes - > "EMOH"
Hope it helps a bit :)
+ 4
in addition to Matteo đœ comment , when the value is more than 1 you can simply escape some characters , for example
when you write str[::-2]
you reverse the string at first then you take character i and escape i+1
for example
"hello"[::-2]
take o leave l
take the first l and leave e
take h and leave nothing and so on