Python Forum
convert list compression to for loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
convert list compression to for loop
#3
hi sir,

this is what i have tried
for x in player_data:
    for y in x.descendants:
        if y.name == "div"
        text = y.text

indices_to_delete = []
for i in range(0, len(text), 250):
    indices_to_delete.append(i)

keys = []
for k in indices_to_delete:
    keys.append(text[k])

new_text = []
for x in text:
    if not x in keys:
        new_text.append(x)
        
has no idea is it correct and how to club them together , all the loops? can someone please tell if it is right or wrong?
Reply


Messages In This Thread
RE: convert list compression to for loop - by Prince_Bhatia - Oct-09-2017, 08:36 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  convert set to a list type in python firaki12345 2 1,788 Feb-05-2021, 03:45 PM
Last Post: buran
  how to edit data frames and convert to a list(pandas, read_html()) ? donvirte 3 4,406 Feb-02-2018, 03:23 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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