Sequence Scans via while, range, for
X = 'test' for item in X: print(item, end=' ') # Simple iteration
You can do it with a while loop:
X = 'test' i = 0 # from w w w . j av a 2 s. co m while i < len(X): # while loop iteration print(X[i], end=' ') i += 1
You can also do manual indexing with a for.
X = 'test' print( len(X) ) # Length of string print( list(range(len(X))) ) # All legal offsets into X # from www .j a va 2s.c o m for i in range(len(X)): print(X[i], end=' ') # Manual range/len iteration