lewisjwilson / terminal_jisho

terminal_jisho provides Japanese-English dictionary search functionality in the Linux command line.
0 stars 0 forks source link

Iterate through list in slices #1

Closed lewisjwilson closed 3 years ago

lewisjwilson commented 3 years ago

Implement the following recursive function and define key presses to scroll through the data

from itertools import islice

# recursive funtion to display slices of a list
def entries(start, stop):
    for item in islice(mylist, start, stop):
        print(item)

    raw = input("Press Enter...")
    if(raw == ""):
        start += 1
        stop += 1
        entries(start, stop)
    elif(start>0):
        start -= 1
        stop -= 1
        entries(start, stop)

mylist = ["感じ", "漢字", "先生", "食べる", "空気", "チーズ", "飲む"]

start = 0
stop = 1

entries(start, stop)