Start New Discussion within our Software Development Community

Okay, so, my main problem here, is that I can't get my parameters from my function name to work with the other variables from the function. Here's the code:

def next_block(x):
    p1 = 2
    p2 = 2.3
    p3 = "c"
    p4 = "String"
    p5 = "3.4444"

    return p1, p2, p3, p4, p5, print (x)

 next_block("testing")
 p1, p2, p3, p4, p5 = next_block()

print (p1)
print (p2)
print (p3)
print (p4)
print (p5)
input()

I'm stumped on this one and I've done lots of experimenting, help would be appreciated.

I'm putting some comments in your code, in dive into python's way

def next_block(x):  # [1]
    ...
    return p1, p2, p3, p4, p5, print (x) # [2]

 next_block("testing") # [3]
 p1, p2, p3, p4, p5 = next_block() # [4]

"""
[1]  This function declares the argument x. It must be called with exactly 1 argument. Correct.
[2]  The function returns a tuple with 6 elements. The last element is the return value of the expression print(x), which is always None. No error.
[3]  Here you call next_block, but you don't do anything with the returned tuple which is lost. It's OK.
[4]  2 errors here: you call next_block without arguments, which contraditcs the function's signature (how it must be called), and you try to assign 5 values from the returned tuple, which won't work because the returned value has length 6.
"""
Comments
great explanation
This question has already been answered. Start a new discussion instead.