Python Forum
Newbie Question re "TypeError: '<' not supported between instances of 'list' and 'int
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newbie Question re "TypeError: '<' not supported between instances of 'list' and 'int
#2
The code shown doesn't produce the error shown
def function_1(x):
    if x < 0:
        return -1000000000
    else:
        return (x ** (1-2)-1)/(1-2)
 
my_list = [1, 2, 3, 4,]
 
print([function_1(i) for i in my_list])
Output:
[-0.0, 0.5, 0.6666666666666667, 0.75]
Note: don't over write the built in list and please post the full error trace back when you have an error.
Reply


Messages In This Thread
RE: Newbie Question re "TypeError: '<' not supported between instances of 'list' and 'int - by Yoriz - Apr-11-2019, 07:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How is pandas modifying all rows in an assignment - python-newbie question markm74 1 765 Nov-28-2023, 10:36 PM
Last Post: deanhystad
  newbie question - can't make code work tronic72 2 744 Oct-22-2023, 09:08 PM
Last Post: tronic72
  Newbie question about switching between files - Python/Pycharm Busby222 3 676 Oct-15-2023, 03:16 PM
Last Post: deanhystad
  Newbie.... run for cover. OpenCV question Stevolution2023 2 1,030 Apr-12-2023, 12:57 PM
Last Post: Stevolution2023
  numpy newbie question bcwilly_ca 4 1,247 Feb-10-2023, 05:55 PM
Last Post: jefsummers
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 4,989 Jul-01-2022, 01:23 PM
Last Post: deanhystad
  TypeError: unsupported opperand type(s) for %: 'int' and 'list' cool_person 7 2,284 May-07-2022, 08:40 AM
Last Post: ibreeden
  TypeError: list indices must be integers or slices, not range Anldra12 2 2,717 Apr-22-2022, 10:56 AM
Last Post: Anldra12
  Noobie Python TypeError question zoid 4 8,015 Sep-01-2021, 02:28 PM
Last Post: zoid
  Question from complete python's newbie Davicom 3 2,450 Jun-09-2021, 06:09 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020