Python Forum
Multiplying number in a list in an order
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiplying number in a list in an order
#5
It's important to understand the slicing syntax.
You can slice lists.

a_list = [0, 1, 2, 3, 4, 5]

left_side = a_list[1:] # [1, 2, 3, 4, 5]
right_side = a_list[:1] # [0]
# left side is from the index 1 to the end
# right side is from start to index 1

rolled_new_list = left_side + right_side # [1, 2, 3, 4, 5, 0]
# + operation on two lists will return a new chained list.
I still hope that someone is coming up with an itertools solution.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
RE: Multiplying number in a list in an order - by DeaD_EyE - Mar-22-2018, 02:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  list digit into number Voldyy 2 1,602 Jul-10-2022, 06:13 PM
Last Post: deanhystad
  Displaying list correspond to the column number danlopek14q 9 4,087 Aug-27-2021, 04:32 AM
Last Post: naughtyCat
  How to convert every even number in a list to odd? Bruizeh 4 3,849 Aug-27-2021, 03:04 AM
Last Post: naughtyCat
  sorting a list using unicodes acending order, no loops, no sort(), using recursion lrn2codee 14 6,575 Jun-23-2021, 07:33 PM
Last Post: deanhystad
  Get the biggest number from a two dimensional list rs74 13 4,150 Aug-09-2020, 04:02 PM
Last Post: deanhystad
  How can I print the number of unique elements in a list? AnOddGirl 5 3,345 Mar-24-2020, 05:47 AM
Last Post: AnOddGirl
  Appending to a list in the right order Noobstudent 2 2,357 Dec-07-2019, 10:39 PM
Last Post: Noobstudent
  adding a number to the list atux_null 4 3,961 Nov-06-2017, 07:01 PM
Last Post: gruntfutuk
  Determine if a list contains a specific number of an item flannel_man 3 4,974 Nov-12-2016, 04:46 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

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