Python Forum
how to remove none from the for loop
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to remove none from the for loop
#2
[i for i in mystr[:1] if i]
You have an interval in the begening in the string " domain ontologies". So when you split it, it returns an empty string as the first index. Which is None in Python. Use strip().

mystr = c.strip(' ').split()
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
how to remove none from the for loop - by desul - Feb-27-2017, 01:30 PM
RE: how to remove none from the for loop - by wavic - Feb-27-2017, 01:46 PM
RE: how to remove none from the for loop - by buran - Feb-27-2017, 01:55 PM
RE: how to remove none from the for loop - by desul - Feb-27-2017, 04:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyKML] Loop through all Placemarks; Remove namespace Winfried 2 3,556 Aug-28-2020, 09:24 AM
Last Post: Winfried
  python multiprocessing import Pool, cpu_count: causes forever loop | help to remove Hassibayub 0 1,929 Jun-18-2020, 05:27 PM
Last Post: Hassibayub

Forum Jump:

User Panel Messages

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