Python Forum
I need to answer this: For the following list, print each element in the list an it’s
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need to answer this: For the following list, print each element in the list an it’s
#1
Heres the code I put
List = ['a','b',1,2,[1,2,3,4],'hello',(4,5,6),7,True,"False",2.3]
for i in List:
    print(i, type)
Output:
a <class 'type'> b <class 'type'> 1 <class 'type'> 2 <class 'type'> [1, 2, 3, 4] <class 'type'> hello <class 'type'> (4, 5, 6) <class 'type'> 7 <class 'type'> True <class 'type'> False <class 'type'> 2.3 <class 'type'>
what am I missing??????
Reply
#2
Add type(i).
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  removing one list element without using its index paul18fr 7 1,445 Feb-22-2025, 07:59 PM
Last Post: DeaD_EyE
  question about changing the string value of a list element jacksfrustration 4 2,317 Feb-08-2025, 07:43 AM
Last Post: jacksfrustration
  extract an element of a list into a string alexs 5 4,315 Aug-30-2024, 09:24 PM
Last Post: alexs
  Strange behavior list of list mmhmjanssen 3 1,748 May-09-2024, 11:32 AM
Last Post: mmhmjanssen
  element in list detection problem jacksfrustration 5 2,023 Apr-11-2024, 05:44 PM
Last Post: deanhystad
  list in dicitonary element problem jacksfrustration 3 1,797 Oct-14-2023, 03:37 PM
Last Post: deanhystad
  No matter what I do I get back "List indices must be integers or slices, not list" Radical 4 2,753 Sep-24-2023, 05:03 AM
Last Post: deanhystad
  How do you get Python to print just one value in a list? 357mag 3 2,282 May-17-2023, 09:52 PM
Last Post: rob101
  Delete strings from a list to create a new only number list Dvdscot 8 3,558 May-01-2023, 09:06 PM
Last Post: deanhystad
  List all possibilities of a nested-list by flattened lists sparkt 1 1,854 Feb-23-2023, 02:21 PM
Last Post: sparkt

Forum Jump:

User Panel Messages

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