Skip to content

Instantly share code, notes, and snippets.

@beltiras
Created September 17, 2018 13:32
Show Gist options
  • Save beltiras/8c4c7b1a1cf01b16d6c55b281ccc398e to your computer and use it in GitHub Desktop.
Save beltiras/8c4c7b1a1cf01b16d6c55b281ccc398e to your computer and use it in GitHub Desktop.
start = int(input("Input a position between 1 and 10:"))
position = start
if start > 10 or start < 1:
exit()
print("l - for moving left")
print("r - for moving right")
print("Any other letter for quitting")
while True:
move = input("Input your choice:")
if move not in "lr":
exit()
if move == "l":
position -= 1
if position < 1:
position = 1
if move == "r":
position += 1
if position > 10:
position = 10
print("New position is:",position)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment