Python Forum
Loop do not start for letter matching algoritm
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loop do not start for letter matching algoritm
#1
Hello,
I make a simple algoritm to compare two strings, but the loop do not continue to the end. This end is the minimum string lenght from these two data entry.

Here's my code :

j1 = "BB"
j2 = "AABBCCDDEEFFGGHHIIJJKKLLMMBBDCCDEEFFGGHHIIJJKKLLMM"

t = 0
tab = []

if len(j1) < len(j2):
    n = len(j1)
else:
    n = len(j2)

for i in range(n):

    while j1[i] == j2[i]:
        t += 1
        tab.append(t)

print(tab)
print(t)
I have this :

[]
0
I must have this type of result:

[1, 2]
2
For AA in the first string = AA to the second string and the loop stop.

Thanks for any help. Big Grin
Reply


Messages In This Thread
Loop do not start for letter matching algoritm - by phob0s - Jul-29-2019, 10:22 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Start loop from different points TheHolyPyGrenade 3 2,096 Apr-11-2021, 07:57 PM
Last Post: TheHolyPyGrenade
  What's the difference b/w assigning start=None and start=" " Madara 1 2,337 Aug-06-2018, 08:23 AM
Last Post: buran
  Can I Control loop with Keyboad key (start/stop) Lyperion 2 3,373 Jul-28-2018, 10:19 AM
Last Post: Lyperion
  Python- Help with try: input() except ValueError: Loop code to start of sequence Aldi 2 6,417 Mar-08-2018, 03:46 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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