I Haz Codes

Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Menu
Forwards and backwards

The code below will traverse over a string going forwards. Without using a second loop, can you get it to display the letters of the word both forwards and backwards at the same time. For example –

input – tiger
tr
ie
gg
ei
rt

word = input("Enter a word")
pos = 0
while pos < len(word):
	print(word[pos])
	pos = pos + 1


You need to log in or create an account to submit code!

Comments are closed.

Information