Say I have the following code:
myVariable = "goodmorning"
I can slice it with e.g. myVariable[1:2]
(like Paolo Bergantino said here: Is there a way to substring a string in Python?), but how can I print some of the characters while jumping over others? e.g. how can I make it print "gdorn"? I tried myVariable[0,3,5,6,7]
(which is wrong as it turns out) and I was thinking to myself that, if myVariable[0,3,5,6,7]
worked then maybe myVariable[0,3,5:7]
would work as well (I hope you see my reasoning), which it doesn't. I am learning Python through codecademy and I didn't cover functions yet, in case you go into functions and such so if there is something easier like what I tried then I would be appreciate it if you explain it!