[Solved] python name error: NameError: name ‘Jewels’ is not defined


You can’t fill a list in this way. Because you start with an empty list, Jewels = [], your attempt to assign to Jewels[0] will result in an IndexError. You can instead use the list.append method

jewels = []
for i in range(total_jewels):
    jewels.append(raw_input('Please Enter approx price for Jewel #{}: '.format(i)))

or a list comprehension

jewels = [raw_input('Please Enter approx price for Jewel #{}: '.format(i)) for i in range(total_jewels)]

1

solved python name error: NameError: name ‘Jewels’ is not defined