Python Forum
List index out of range error when attempting to make a basic shift code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
List index out of range error when attempting to make a basic shift code
#5
(Aug-16-2020, 06:22 PM)bowlofred Wrote: Consider
            new_position %= len(alphabet)
Works for positive and negative values. No need for an if.
x = -2 % 26
y = 28 % 26
print(x, y)
Output:
24 2
Reply


Messages In This Thread
RE: List index out of range error when attempting to make a basic shift code - by deanhystad - Aug-16-2020, 08:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  hi need help to make this code work correctly atulkul1985 5 808 Nov-20-2023, 04:38 PM
Last Post: deanhystad
  newbie question - can't make code work tronic72 2 708 Oct-22-2023, 09:08 PM
Last Post: tronic72
  Cleaning my code to make it more efficient BSDevo 13 1,389 Sep-27-2023, 10:39 PM
Last Post: BSDevo
  Why do I have to repeat items in list slices in order to make this work? Pythonica 7 1,369 May-22-2023, 10:39 PM
Last Post: ICanIBB
  pyscript index error while calling input from html form pyscript_dude 2 1,003 May-21-2023, 08:17 AM
Last Post: snippsat
  Index error help MRsquared 1 786 May-15-2023, 03:28 PM
Last Post: buran
Thumbs Down I hate "List index out of range" Melen 20 3,370 May-14-2023, 06:43 AM
Last Post: deanhystad
  how to make bot that sends instagram auto password reset code kraixx 2 1,415 Mar-04-2023, 09:59 PM
Last Post: jefsummers
  Find a shift between 2 pictures TazFleck 0 1,176 Jan-18-2023, 09:56 PM
Last Post: TazFleck
  help me to make my password list in python >>> Oktay34riza 0 593 Dec-23-2022, 12:38 PM
Last Post: Oktay34riza

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020