Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keep the longest chains
#4
Try this
L1=[]
L2=[]
L3=[]
L4=[]
with open ("C:/Users/lveillat/Desktop/Données stage/Fichiers tests/test_retrait_chaines_intermediaire.txt","r") as f1:
 
    for lignes in f1:
        lignes=lignes.rstrip('\n')
        L1.append (lignes)
        L2.append (lignes)
 
    for i in L1:
        if i not in L4:
         
            L4.append(i)
            L3.append(i)
        else:
            continue
 
        for j in L2:
            if i in j or j in i:
                if i != j:
                    L4.append(j)
                    L3.append(j)
            i = j
 
        print(L3)
        L3.clear()

Hope this works
Reply


Messages In This Thread
Keep the longest chains - by Amniote - Jul-03-2019, 08:57 AM
RE: Keep the longest chains - by perfringo - Jul-03-2019, 09:22 AM
RE: Keep the longest chains - by Amniote - Jul-03-2019, 01:24 PM
RE: Keep the longest chains - by SheeppOSU - Jul-03-2019, 01:47 PM
RE: Keep the longest chains - by perfringo - Jul-03-2019, 02:03 PM
RE: Keep the longest chains - by Amniote - Jul-03-2019, 03:12 PM
RE: Keep the longest chains - by perfringo - Jul-03-2019, 03:32 PM
RE: Keep the longest chains - by nilamo - Jul-03-2019, 03:19 PM
RE: Keep the longest chains - by Amniote - Jul-03-2019, 03:24 PM
RE: Keep the longest chains - by nilamo - Jul-03-2019, 03:32 PM
RE: Keep the longest chains - by Amniote - Jul-03-2019, 04:51 PM
RE: Keep the longest chains - by nilamo - Jul-03-2019, 05:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python code for Longest Common Subsequence Bolt 3 1,009 Sep-22-2023, 08:09 AM
Last Post: Bolt
  Python implementation of Longest Common Substring problem Bolt 0 600 Sep-17-2023, 08:31 PM
Last Post: Bolt
  longest palindromic subsequence DP solution bug usercat123 9 2,447 Feb-05-2022, 06:00 AM
Last Post: deanhystad
  Longest sequence of repeating integers in a numpy array Cricri 5 5,854 Jun-08-2020, 06:48 AM
Last Post: Cricri

Forum Jump:

User Panel Messages

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