Q:

Why am I encountering a value error - (empty range for randrange)

I'm currently making a small python game and have run into this error: "ValueError: empty range for randrange() (1,1, 0)"
The code is simply running through a quiz using a quiz array (quiz1)
I can't seem to work out why this is happening, my hunch is that the range eventually gets to range(1,0) somehow even though it should stop.
test = len(quiz1)
while test>=1:
  questionNumber = random.randint(1,(len(quiz1)-1))
  question = quiz1.pop(questionNumber) 
  print(question[0])
  qnum = 1
  for i in question[1]:
    print(qnum, ".", i)
    qnum += 1

The array used is as follows
quiz1 = ['Dinosaur Quiz', ['What is the largest dinosaur thought to have existed?',['Argentinosaurus', 'Spinosaurus', 'Brachiosaurus'], 0],
                      ['Did Tyrannosaurus rex have feathers along its body?', ['Yes','No'], 1],
                      ['How tall was Velociraptor?',['3ft', '5ft', '7ft'], 0],
                      ['How many major geological time periods were there in the Mesozoic era?', ['1', '5', '3'], 2],
                      ['Who discovered and named the first Utahraptor specimen?',['James Kirkland','Jack Horner', 'Carl Limoni'], 0],
                        ]

The while loop (while test>= 1) should stop the loop running when the the randrange is an empty range but it continues. Does anyone know why I'm encountering the error? (ValueError: empty range for randrange() (1,1, 0))

A:

I modified your code to put in correct formatting and some missing punctuation (see below). The problem is you have:
test = len(quiz1)
while test>=1: #missing colon added

But test is never modified in the loop, which must now loop indefinitely. Every time you pop a value from quiz1, its length is reduced by 1 and eventually will have a length of 1. When that happens, the second parameter in the call to randint will be 0 while the first parameter is 1 and that is an impossible range.
Corrected code:
import random

quiz1 = ['Dinosaur Quiz', ['What is the largest dinosaur thought to have existed?',['Argentinosaurus', 'Spinosaurus', 'Brachiosaurus'], 0],
                      ['Did Tyrannosaurus rex have feathers along its body?', ['Yes','No'], 1],
                      ['How tall was Velociraptor?',['3ft', '5ft', '7ft'], 0],
                      ['How many major geological time periods were there in the Mesozoic era?', ['1', '5', '3'], 2],
                      ['Who discovered and named the first Utahraptor specimen?',['James Kirkland','Jack Horner', 'Carl Limoni'], 0],
                        ]

while len(quiz1)>1:
    questionNumber = random.randint(1,(len(quiz1)-1))
    question = quiz1.pop(questionNumber)
    print(question[0])
    qnum = 1
    for i in question[1]:
        print(qnum, ".", i)
        qnum += 1

Your loop:
    qnum = 1
    for i in question[1]:
        print(qnum, ".", i)
        qnum += 1

Can be simplified and neatened up with:
    for n, q in enumerate(question[1]):
        print(n + 1, ". ", q, sep='')

Or if you are running with Python 3.6 or greater:
    for n, q in enumerate(question[1]):
        print(f'{n + 1}. {q}')

Or for any version of Python:
    for n, q in enumerate(question[1]):
        print('{}. {}'.format(n + 1, q))

