CSc 120: Shift a tuple
Expected Behavior
Write a function shift_tuple(tup, value) that
takes as arguments a tuple tup of length n and a valuevalue.
The function returns a new tuple
consisting of the elements 1 through n-1 of tup and value.
Note: Do not use recursion to solve this problem.
Examples
-
shift_tuple(('one', 'two', 'three'), 'four'))
Return value: ('two', 'three', 'four')
-
shift_tuple(('Half', 'a'), 'bee')
Return value: ('a', 'bee')
-
shift_tuple(('a', 'bee'), 'philosophically')
Return value: ('bee', 'philosophically')
-
shift_tuple(tuple(), 'one')
Return value: ('one',)