Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Printing empty list?
#3
If the way your code is indented is the way it is in your code snippet, you just have to indent the lines after your for loop as shown below. Hope that helps =]

def kasinski(text):
    trigraphs=[]
    distances=[]
    for trigraph in range (len(text)-2):
        newtrigraph= text[trigraph:trigraph+3]
        if newtrigraph in trigraphs:
            distances.append(trigraph-(text.index(newtrigraph)))
        else:
            trigraphs.append(newtrigraph)
            trigraphs.append(trigraph)
        return distances
Reply


Messages In This Thread
Printing empty list? - by hhydration - Oct-28-2020, 12:56 AM
RE: Printing empty list? - by deanhystad - Oct-28-2020, 02:13 AM
RE: Printing empty list? - by Atekka - Oct-28-2020, 11:34 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  what to return for an empty list Skaperen 2 1,198 May-24-2024, 05:17 PM
Last Post: Skaperen
  Code with empty list not executing adeana 9 5,811 Dec-11-2023, 08:27 AM
Last Post: buran
  set.difference of two list gives empty result wardancer84 4 2,580 Jun-14-2022, 01:36 PM
Last Post: wardancer84
Question Printing through list.. again jesse68 2 1,760 Apr-16-2022, 03:24 PM
Last Post: jesse68
  displaying empty list vlearner 5 2,935 Jan-19-2022, 09:12 AM
Last Post: perfringo
  Remove empty keys in a python list python_student 7 5,491 Jan-12-2022, 10:23 PM
Last Post: python_student
  help for list printing jip31 8 5,138 May-01-2021, 03:52 AM
Last Post: Pedroski55
  What is the value after JOINING an empty list? JaneTan 2 7,387 Jan-04-2021, 06:25 PM
Last Post: deanhystad
  Problem printing last element from a list tester_V 3 3,960 Oct-30-2020, 04:54 AM
Last Post: tester_V
  Stop a function if the list it needs is empty Pedroski55 2 4,218 Jul-25-2020, 11:50 PM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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