So Im trying to prompt the user to enter strings until they enter an empty string.
Then i want to add all the strings to a list and using recursion I want to print the reversed list to the screen.
I keep getting 'None' printed instead. What am I missing from this? or doing wrong?

def recur(x):

while True:

    userinput = input("Enter a string: ")
    if userinput == "": break

    elif userinput != "":
        return recur(lists)

print(recur(x = lists))

While I think your code was badly formatted, let's look at

Since you break on line 4 the remaining code does not execute and thus no return of the list. Since all we need is to return to end the while loop, how about the following? I did not bother to name variables here. Quick and dirty. The reason for the print is to see the list build.

def that():
    l = []
    while True:
        userinput = input("Enter a string: ")
        if not userinput: return l

commented: Appreciate it. Yea I'm literally a newbie at Python so I haven't learned anything more in depth. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.