Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8827367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:21:17+00:00 2026-06-14T07:21:17+00:00

list1 = [1,2,3,4,5,6,7,8,9] def replace(): input_list = input(Enter three numbers separated by commas: )

  • 0
list1 = [1,2,3,4,5,6,7,8,9]
def replace():

    input_list = input("Enter three numbers separated by commas: ")
    list2 = input_list.split(',')
    list2 = [int(x.strip())for x in list2]

    del list1[-3:]
    list1.insert(0,list2)

    print(list1)

for input 12,13,14
this gives as a result [[12,13,14],1,2,3,4,5,6]
Firstly I would like to have a ‘flat’ list as the result and can’t seem to get this right [12,13,14,1,2,3,4,5,6]. I can get the last value entered as part of the list by removing the square brackets from the list2=[int(x.strip()) for…] statement, gives [14,1,2,3,4,5,6].
My second wish is that I can change the initial list permanently ie [12,13,14,1,2,3,5,6] becomes list1 that is called in the first place. Do I need to save this as a csv file and write to it? I am very new to this, so please forgive me if this is a very simple or stupid batch of questions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:21:18+00:00Added an answer on June 14, 2026 at 7:21 am

    I believe this is what you want:

    In [11]: list1 = [1, 2, 3, 4, 5, 6]
    
    In [12]: list2 = [12, 13, 14]
    
    In [13]: list1[0:0] = list2
    
    In [14]: list1
    Out[14]: [12, 13, 14, 1, 2, 3, 4, 5, 6]
    

    The slice operation changes list1 in-place, so the variable isn’t simply pointing at a new list. I think that’s what you meant by “permanently”?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

def replace(): import tkinter.filedialog drawfilename = tkinter.filedialog.askopenfilename() list1= int(open(drawfilename,'w')) del list1[-3:] input_list = input(Enter
I got a function like def f(): ... ... return [list1, list2] this returns
def fibSeq(n: Int): List[Int] = { var ret = scala.collection.mutable.ListBuffer[Int](1, 2) while (ret(ret.length -
@with_checker([int]) def check_sort(list_of_ints): self.assertTrue(isinstance(list_of_ints, list)) self.assertTrue(len(list) == len(qsort(list))) self.assertTrue(False) I'm trying to run this,
I am writing a program like unix tr, which can replace string of input.
i am doing this: def GetDistinctValues(theFile, theColumn): lines=theFile.split('\n') allValues=[] for line in lines: allValues.append(line[theColumn-1])
I am using multiprocessing.imap_unordered to perform a computation on a list of values: def
What's going on here? I'm trying to create a list of functions: def f(a,b):
Trying to solve a problem with templatetags. I have two templatetags: @register.inclusion_tag('directory/_alphabet.html') def alphabet_list(names):
consider this simple function def foo(l=[]): if not l: print List is empty else

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.