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

  • Home
  • SEARCH
  • 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 6663843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:32:38+00:00 2026-05-26T02:32:38+00:00

I am writing a simple sort program in python and encounter this error. I

  • 0

I am writing a simple sort program in python and encounter this error. I want to swap list elements but it returns an error. I am attaching the error and program in question below.

list[i+1] = list[i]
TypeError: 'tuple' object does not support item assignment

Code:

def my_sort(list):
    for index in range(1,len(list)):
        value=list[index]
        i=index-1
        while i>=0:
            if value<list[i]:
                list[i+1] = list[i]
                list[i]=value
                i=i-1
            else:
                break
    return

    input_list=eval(input("Enter list items"))
    my_sort(input_list)
    print(input_list)
  • 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-05-26T02:32:39+00:00Added an answer on May 26, 2026 at 2:32 am

    Evaluating “1,2,3” results in (1, 2, 3), a tuple. As you’ve discovered, tuples are immutable. Convert to a list before processing.

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

Sidebar

Related Questions

I'm writing a simple linear linked list implementation in PHP. This is basically just
I have sort of a simple question. I am writing an Objective-C program with
I'm writing simple program to communicate between smart devices and I receive 11001 when
I'm writing a simple OpenGL application that uses GLUT . I don't want to
Okay, so this is sort of a hack...but it may have to be. I'm
I am writing a program in OpenGL and I need some sort of interfacing
I'm writing a C++ program and I need some help understanding an error. By
I'm writing a simple little file-syncing daemon in python to implement a synchronised file
I am writing a simple merge sort function to sort based on a given
I am trying to learn how to use JSON and writing a simple program

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.