Python Forum
removing quotes from a list and keep type list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
removing quotes from a list and keep type list
#3
start will be a str, so you can do something like

use map
>>> start = '192.168.1.99'
>>> start = list(map(int, start.split('.'))) # you need to convert the map object to list
>>> start
[192, 168, 1, 99]
or use list comprehension
>>> start = '192.168.1.99'
>>> start = [int(num) for num in start.split('.')]
>>> start
[192, 168, 1, 99]
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: removing quotes from a list and keep type list - by buran - Aug-03-2019, 10:49 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Strange behavior list of list mmhmjanssen 2 185 May-01-2024, 07:16 AM
Last Post: Gribouillis
  No matter what I do I get back "List indices must be integers or slices, not list" Radical 4 1,226 Sep-24-2023, 05:03 AM
Last Post: deanhystad
  Delete strings from a list to create a new only number list Dvdscot 8 1,579 May-01-2023, 09:06 PM
Last Post: deanhystad
  List all possibilities of a nested-list by flattened lists sparkt 1 945 Feb-23-2023, 02:21 PM
Last Post: sparkt
  Сheck if an element from a list is in another list that contains a namedtuple elnk 8 1,881 Oct-26-2022, 04:03 PM
Last Post: deanhystad
Question Keyword to build list from list of objects? pfdjhfuys 3 1,601 Aug-06-2022, 11:39 PM
Last Post: Pedroski55
  search a list or tuple for a specific type ot class Skaperen 8 1,979 Jul-22-2022, 10:29 PM
Last Post: Skaperen
  TypeError: unsupported opperand type(s) for %: 'int' and 'list' cool_person 7 2,247 May-07-2022, 08:40 AM
Last Post: ibreeden
  unsupported operand type(s) for %: 'list' and 'int' RandomCoder 4 32,935 May-07-2022, 08:07 AM
Last Post: menator01
  Split a number to list and list sum must be number sunny9495 5 2,335 Apr-28-2022, 09:32 AM
Last Post: Dexty

Forum Jump:

User Panel Messages

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