close

[Solved] (Python) TypeError: ‘float’ object is not subscriptable

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error (Python) TypeError: ‘float’ object is not subscriptable in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How (Python) TypeError: ‘float’ object is not subscriptable Error Occurs?

Today I get the following error (Python) TypeError: ‘float’ object is not subscriptable in python.

How To Solve (Python) TypeError: ‘float’ object is not subscriptable Error ?

  1. How To Solve (Python) TypeError: 'float' object is not subscriptable Error ?

    To Solve (Python) TypeError: 'float' object is not subscriptable Error PriceList[0] is a float. PriceList[0][1] is trying to access the first element of a float. Instead, do

  2. (Python) TypeError: 'float' object is not subscriptable

    To Solve (Python) TypeError: 'float' object is not subscriptable Error PriceList[0] is a float. PriceList[0][1] is trying to access the first element of a float. Instead, do

Solution 1

PriceList[0] is a float. PriceList[0][1] is trying to access the first element of a float. Instead, do

PriceList[0] = PriceList[1] = ...code omitted... = PriceList[6] = PizzaChange

or

PriceList[0:7] = [PizzaChange]*7

Solution 2

PriceList[0][1][2][3][4][5][6]

This says: go to the 1st item of my collection PriceList. That thing is a collection; get its 2nd item. That thing is a collection; get its 3rd…

Instead, you want slicing:

PriceList[:7] = [PizzaChange]*7

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read