Q:

Python: Change range location with loop

I would like my program to print every other letter in the string "welcome".
like:
e
c
m

Here is the code I have so far:
stringVar = "welcome"
countInt = 7

count = 0
oneVar = 1
twoVar = 2

showVar = stringVar[oneVar:twoVar]

for count in range(countInt):
count = count + 1
oneVar = oneVar + count
twoVar = twoVar + count

print(showVar)

Though it only shows the 2nd letter "e".
How can I get the variables oneVar and twoVar to update so that the range changes for the duration of the loop?

A:

There is a built in notation for this, called "slicing":
>>> stringVar = "welcome"
>>> print(stringVar[::2])
wloe
>>> print(stringVar[1::2])
ecm

stringVar is iterable like a list, so the notation means [start : end : step]. Leaving any one of those blank implicitly assumes from [0 : len(stringVar) : 1]. For more detail, read the linked post.

