Skip to content
Snippets Groups Projects
2.7 Exercises.py 509 B
Newer Older
# question 1
Michael Mutote's avatar
Michael Mutote committed
def rotateR(val):
Michael Mutote's avatar
Michael Mutote committed
    return val[-1] + val[1:len(val)] if len(val) > 0 else None
Michael Mutote's avatar
Michael Mutote committed


Michael Mutote's avatar
Michael Mutote committed
# question 4
def rotateRx(val):
Michael Mutote's avatar
Michael Mutote committed
    pass

Michael Mutote's avatar
Michael Mutote committed


# question 5
Michael Mutote's avatar
Michael Mutote committed
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

Michael Mutote's avatar
Michael Mutote committed