Newer
Older
# question 2
def rotateL(val):
return val[:-1] + val[0] if len(val) > 0 else None
# question 3
"""
The provided functions rotateR and rotateL are designed to work with both strings and lists.
There's no issue with their functionality for either data type.
example rotateR using strings and lists -- rotateR("abc") == "cab" and rotateR([1,2,3,4]) == [4,1,2,3]
example rotateL using strings and lists -- rotateL("abc") == "bca" and rotateL([1,2,3,4 ]) == [2,3,4,1]
"""
def rotateRx_modified(val):
# cannot be modified to work for strings, without returning a value. Python strings are immutable. They cannot be
# modified once they are created:
# ```TypeError: 'str' object does not support item assignment```
# So the only way to achieve this would be to return a value and assign it back.
pass