Python Forum
modifying a list in an expression
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
modifying a list in an expression
#1
i have some incoming data. each unit of data can be converted to a list. that list can be converted back to that data. the conversions are expressions. i can nest these two expression to convert the data to a list and then back. i have a modification to the data that is defined in terms of it being in the list form. the modification is copying element index B to element index A of the list like. i can do this in 3 lines:

    temp = convert_data_to_list(data)
    temp[A] = temp[B]
    data = convert_list_to_data(temp)
is there an easy way to use slicing (or something else) to make this all be a single expression?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
modifying a list in an expression - by Skaperen - Feb-14-2019, 04:25 AM
RE: modifying a list in an expression - by Skaperen - Feb-15-2019, 07:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  List Creation and Position of Continue Statement In Regular Expression Code new_coder_231013 3 1,676 Jun-15-2022, 12:00 PM
Last Post: new_coder_231013
  Modifying code cheburashka 1 1,305 Dec-13-2021, 01:01 PM
Last Post: Kebap
  Regular expression: return string, not list Pavel_47 3 2,507 Jan-14-2021, 11:49 AM
Last Post: Pavel_47
  Pass results of expression to another expression cmdr_eggplant 2 2,297 Mar-26-2020, 06:59 AM
Last Post: ndc85430
Question Why does modifying a list in a for loop not seem to work? umut3806 2 2,307 Jul-22-2019, 08:25 PM
Last Post: umut3806
  iterate through a list with comparison of expression Alexandro 6 3,421 Jan-31-2019, 05:16 PM
Last Post: Scorpio
  Is there a way to append to a list WITHOUT modifying the parameter passed? arnavb 11 5,719 Sep-23-2018, 07:16 AM
Last Post: Skaperen
  Modifying / extracting multiple list items simultaneously using variable from range ehammarlund 4 3,713 Dec-06-2017, 08:15 PM
Last Post: ehammarlund
  Modifying Lists RedSkeleton007 12 6,842 Nov-22-2017, 04:31 AM
Last Post: heiner55
  list comprehension with regular expression aibrain 1 4,464 May-22-2017, 11:41 AM
Last Post: zivoni

Forum Jump:

User Panel Messages

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