Python Forum
Can anyone spot why this function is returning an empty list?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can anyone spot why this function is returning an empty list?
#1
def affine_n_encode(text, n, a,b):
    ngraphs=[]
    nums=[]
    texts=[]
    if len(text) % n==0:
        for i in range(len(text)):
            ngraphs.append(text[i:i+n])
        else:
            list(text)
            text.append(['x']*(len(text)%n))
            ''.join(text)
            ngraphs.append(text[i:i+n])
    for n_graph in ngraphs:
        nums.append(convert_to_num(n_graph))
    for num in nums:
        texts.append(convert_to_text(((a*(num)+b)%26),n))
        ''.join(texts)
    return texts
text = "THEQUICKBROWNFOXJUMPEDOVERTHELAZYDOG"
enc = affine_n_encode(text, 5, 347, 1721)

print(enc)
Edit: Please let me know if you need any more information about the function to understand the problem
Reply


Messages In This Thread
Can anyone spot why this function is returning an empty list? - by hhydration - Nov-17-2020, 04:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why does this function print empty list? hhydration 1 1,565 Oct-28-2020, 02:03 AM
Last Post: deanhystad
  [supernoob] Can't spot the error... sidon 2 2,153 Jul-12-2019, 12:19 PM
Last Post: sidon
  why is this not filling my empty list? Siylo 4 3,238 Jan-21-2019, 05:27 PM
Last Post: Siylo
  help returning a list lga13 1 2,097 Dec-01-2018, 10:18 PM
Last Post: Larz60+
  Why is this function returning none? wlsa 2 5,855 Sep-30-2018, 01:36 PM
Last Post: gruntfutuk
  Issues with Inserting Values into an Empty List with a While Loop TommyMer 2 3,816 Sep-12-2018, 12:43 AM
Last Post: TommyMer
  why is the append function gets empty on the loop?/python rhai 3 3,286 Jul-07-2018, 12:19 PM
Last Post: rhai
  Function not returning correct value TsG009 4 4,208 Nov-24-2017, 09:07 PM
Last Post: sparkz_alot
  Function for returning absolute numbers Ernstblack 2 3,252 Oct-02-2017, 05:48 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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