Skip to main content
typos to make a very good answer fractionally better
Source Link

You have splittedsplit your code into multiple functions, documented them, and written the usual if __name-- == 'main': test : this is already a pretty good beginning.

Also, pep8 only complies about some whitespaceswhitespace not following the Python Style Guide (this is worth fixing it anyway).

  • your code can be python 3 compliant by adding parenthesisparentheses in your calls to print.
  • you have the same typo rorate in multiple places
  • list is a bad name for a list as you can easily mix-up with the type
  • your function and variable names doesdo not follow the convention.

In Programming Pearls (sorry I couldn't find the relevant full text), Jon Bentley describes different solutions to the problem. Some behindare quite original and actually very easy to implement on top of being efficient. I'll let you google "programming pearls rotate" if you want to read more about this. It is defintlydefinitely worth a read (and the whole book is too).

You have splitted your code into multiple functions, documented them, written the usual if __name-- == 'main': test : this is already a pretty good beginning.

Also, pep8 only complies about some whitespaces not following the Python Style Guide (this is worth fixing it anyway).

  • your code can be python 3 compliant by adding parenthesis in your calls to print.
  • you have the same typo rorate in multiple places
  • list is a bad name for a list as you can easily mix-up with the type
  • your function and variable names does not follow the convention.

In Programming Pearls (sorry I couldn't find the relevant full text), Jon Bentley describes different solutions to the problem. Some behind quite original and actually very easy to implement on top of being efficient. I'll let you google "programming pearls rotate" if you want to read more about this. It is defintly worth a read (and the whole book is too).

You have split your code into multiple functions, documented them, and written the usual if __name-- == 'main': test : this is already a pretty good beginning.

Also, pep8 only complies about some whitespace not following the Python Style Guide (this is worth fixing it anyway).

  • your code can be python 3 compliant by adding parentheses in your calls to print.
  • you have the same typo rorate in multiple places
  • list is a bad name for a list as you can easily mix-up with the type
  • your function and variable names do not follow the convention.

In Programming Pearls (sorry I couldn't find the relevant full text), Jon Bentley describes different solutions to the problem. Some are quite original and actually very easy to implement on top of being efficient. I'll let you google "programming pearls rotate" if you want to read more about this. It is definitely worth a read (and the whole book is too).

added 450 characters in body
Source Link
SylvainD
  • 29.8k
  • 1
  • 49
  • 93

And more generally

In Programming Pearls (sorry I couldn't find the relevant full text), Jon Bentley describes different solutions to the problem. Some behind quite original and actually very easy to implement on top of being efficient. I'll let you google "programming pearls rotate" if you want to read more about this. It is defintly worth a read (and the whole book is too).

And more generally

In Programming Pearls (sorry I couldn't find the relevant full text), Jon Bentley describes different solutions to the problem. Some behind quite original and actually very easy to implement on top of being efficient. I'll let you google "programming pearls rotate" if you want to read more about this. It is defintly worth a read (and the whole book is too).

added 663 characters in body
Source Link
SylvainD
  • 29.8k
  • 1
  • 49
  • 93
            ...
            copy_digit(lst, i + 1, item_to_shift)
            ...
        ...
lst[i + 1] = item_to_shift
...
 

Then, it seems like the item_to_shift variable is not really required anymore :

for i in range(len(lst) - 2, -1, -1):
    lst[i + 1] = item_to_shift
            ...lst[i]
            ...
            copy_digit(lst, i + 1, item_to_shift)
            ...
            ...
            lst[i + 1] = item_to_shift
            ...
...
copy_digit(lst, i + 1, item_to_shift)
...
...
lst[i + 1] = item_to_shift
...

Then, it seems like the item_to_shift variable is not really required anymore :

for i in range(len(lst) - 2, -1, -1):
    lst[i + 1] = lst[i]
added 663 characters in body
Source Link
SylvainD
  • 29.8k
  • 1
  • 49
  • 93
Loading
added 2098 characters in body
Source Link
SylvainD
  • 29.8k
  • 1
  • 49
  • 93
Loading
Source Link
SylvainD
  • 29.8k
  • 1
  • 49
  • 93
Loading