close

[Solved] TypeError: ‘<' not supported between instances of 'list' and 'int'

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error TypeError: ‘<‘ not supported between instances of ‘list’ and ‘int’ 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 TypeError: ‘<‘ not supported between instances of ‘list’ and ‘int’ Error Occurs?

Today I get the following error TypeError: ‘<‘ not supported between instances of ‘list’ and ‘int’ in Python.

How To Solve TypeError: ‘<‘ not supported between instances of ‘list’ and ‘int’ Error ?

  1. How To Solve TypeError: '

    To Solve TypeError: '<' not supported between instances of 'list' and 'int' Error Your million/billion/… variables are all lists. Send in million[0] to specify the int 1000000 in the 0th index of the list million and you get an answer out '$14000000000000T'

Solution 1

You have a lot of issues where you don’t distinguish between lists and integers.

million = [1000000, "M"]
billion = [million * 1000, "B"]

billion[0] is not actually a 1000000 * 1000, its a length 1000 list.

This is the root of all your problems, since now suffix[0] becomes a list after the first iteration through your loop. The biggest change you needed was as follows:

million = [1000000, "M"]
billion = [million[0] * 1000, "B"]
trillion = [billion[0] * 1000, "T"]
quadrillion = [trillion[0] * 1000, "Qd"]
quintillion = [quadrillion[0] * 1000, "Qn"]
sx = [quintillion[0] * 1000, "Sx"]
septillion = [sx[0] * 1000, "Sp"]

This makes sure that each of these is a two element list with the proper suffix and value. Here it is all together:

suffixes = [million, billion, trillion, quadrillion, quintillion, sx, septillion]

def getSetupResult(orevalue, furnacemultiplier, *upgrades, **kwargs):
    for i in upgrades:
        orevalue *= i
    orevalue *= furnacemultiplier
    for suffix in suffixes:
        if orevalue > suffix[0] - 1 and orevalue < suffix[0] * 1000:
            print("$"+str(orevalue)+suffix[1])
getSetupResult(quintillion[0],700,5,4,10,100)

Output:

$14000000000000000000000000Sp

Solution 2

Your million/billion/… variables are all lists. Send in million[0] to specify the int 1000000 in the 0th index of the list million and you get an answer out ‘$14000000000000T’

Also, when you * a list you are just copying out that list how ever many times you multiply it by. So your million * 1000 needs to be million[0] * 1000 and so on.

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

Leave a Comment