Question: I'm trying to implement a simple paging system with c# and cosmos on my Vue front end, but i'm not really sure the best way to implement a the paging when the user wants to go back.

For going forward i'm using the continuation token, so cosmos know where i have got up to, but i'm not really sure on the best way to work this going backwards, or if the user goes from page 1 to 3, then back to page 2?

Will i have to cache the results as the user pages through the items, or is there another way to accomplish this?

Answer: 
I have tried to create a python 2 / 3 answer.

python 2 `input` interprets your input, converting to integers if possible for instance. So you cannot have an integer AND a string. When entering `quit`, since `quit` isn't known by the interpreter, you get a `NameError`

The only way to make it work would be to type `"quit"`. But that'd be python 2 only still... Let's try to make it portable now.

python 3 fails when comparing strings to numbers, because `input` returns strings.

You'll have a hard time creating a code which works for both versions. I'd suggest this:

```
import random

# detect/create a portable raw_input for python 2/3
try:
    raw_input
except NameError:
    raw_input = input

while True:
    ROLL=raw_input("What sided Die would you like to roll(You may enter quit to close)? ")
    if ROLL.isdigit():
        ROLL = int(ROLL)

    if ROLL in [6,8,10,12,20]:
        print(random.randint(1, ROLL))
    elif ROLL == "quit":
        break
    else:
        print("That's not an option please choose a die...")

```

The first `try`/`except` block is there for python 2/3 compatibility. If `raw_input` exists, use it, else define it as `input` for python 3. From now on, `raw_input` is used, and returns *strings* not integers.

Now we have to add this: `if ROLL.isdigit()` tests if the string could be converted as an integer. If it's possible, it converts it.

Now we test if the reply is contained in the choice list, and if it is, we use `ROLL` for our random (avoids the ton of `elif` statements).

The loop has been turned to inconditional too, no need to initialize `ROLL` at start. Just `break` if `quit` is entered.
The main error in your code is that `input` returns a string and you are comparing it to integers. By example `'6'` is not equal to `6`.

Although, you could simplify your code greatly by comparing the input to a tuple of allowed value. This will be both shorter and more extendable.

```
from random import randint

while True:
    roll = input("What sided Die would you like to roll(You may enter quit to close)? ")

    if roll == 'quit':
        break
    elif roll in ('6', '8', '10', '12', '20'):
        print(randint(1, int(roll)))
    else:
        print("That's not an option please choose a die...")

print("Thank you")

```