My professor assigned a project in which we perform a series of alterations to a list. We are provided with a main function such as:
CURRENT_LIST = [1,2,3,4,5]
def main():
data = list(CURRENT_LIST)
shiftRight(data)
print("After shifting data", data)
Basically, we have to write functions that handle these functions that main()
is calling. I understand how to write the functions. For example, shifting everything to the right would yield something like:
def shiftRight(data:list) -> (list):
data = data[-1:] + data[:-1]
return(data)
My question is: is it possible to do this without altering the main()
function we were provided with? From my understanding, after calling shiftRight()
, I would have to assign it to the list again. Something like:
data = shiftRight(data)
But the main function we were provided with is not set up like that. I am wondering if I can reassign the data
list without modifying the main()
function. I would like to avoid using global variables as well, as I don't think that was my professor's intention.
Has he made a mistake in the main()
we were provided with? Or is there truly a way to modify this list without using global variables
and without modifying main()
?