If what you were trying to do was pass it a tuple with one list inside, this was answered by @interjay in the comments but, you're not actually passing the function a tuple. For example:
list, # not a tuple, just a single list
(list,) # valid tuple with single list inside
More examples:
list # one list
list, # one list
(list) # also one list
(list,) # tuple with one list inside
(list, list) # tuple with two lists inside
(list, list,) # tuple with two lists inside
Also the function is written to accept a single list. If you pass it a tuple, you have to handle for a tuple.
Currently if you pass this function a tuple whose len is less than or equal to 1, it will return None; However if the tuple has more than one item inside, it will break:
your_function((item,)) # returns None since len is 1
your_function((item, item2)) # breaks program
your_function((item, item2,)) # breaks program
To fix this add a check to your function:
if (type(list_of_elements) != list): return
like this:
def rotated_left(list_of_elements):
if (type(list_of_elements) != list): return
if len(list_of_elements) > 1:
print(len(list_of_elements))
first_element = list_of_elements[0]
for i in range(len(list_of_elements) - 1):
list_of_elements[i] = list_of_elements[i+1]
list_of_elements[-1] = first_element
return list_of_elements
Things to remember
li = [1,2,3] # makes a list
tu = li, # makes a tuple with li
your_function(li,) # passes a list to your function
# does not make a tuple and pass it to your function