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
  element in list detection problem jacksfrustration 5 355 Apr-11-2024, 05:44 PM
Last Post: deanhystad
  list in dicitonary element problem jacksfrustration 3 698 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 1,170 Sep-24-2023, 05:03 AM
Last Post: deanhystad
  How do you get Python to print just one value in a list? 357mag 3 1,013 May-17-2023, 09:52 PM
Last Post: rob101
  Delete strings from a list to create a new only number list Dvdscot 8 1,534 May-01-2023, 09:06 PM
Last Post: deanhystad
  List all possibilities of a nested-list by flattened lists sparkt 1 919 Feb-23-2023, 02:21 PM
Last Post: sparkt
  Find (each) element from a list in a file tester_V 3 1,212 Nov-15-2022, 08:40 PM
Last Post: tester_V
  Сheck if an element from a list is in another list that contains a namedtuple elnk 8 1,837 Oct-26-2022, 04:03 PM
Last Post: deanhystad
Question Keyword to build list from list of objects? pfdjhfuys 3 1,565 Aug-06-2022, 11:39 PM
Last Post: Pedroski55
  Membership test for an element in a list that is a dict value for a particular key? Mark17 2 1,211 Jul-01-2022, 10:52 PM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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