Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • How to Update Tuples in Python Programming Language

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 858
    Comment on it

    In python tuple is an immutable objects means it can not be changed, only we can create. Alike list tuple are a sequence but the difference is tuple use parentheses "()" where as list uses square brackets [ ] and list can be changed where as tuple cannot.

     

     

    In tuples we can not update or change the value, as a reason I stated above it is because tuples are immutable means can't change or modifie but only can be updated if their are more then one tuple. Only we take portions of existing tuples to create a new tuples.

    Tuple is fast: The size of an element is pre calculated in Elixir which makes the process of finding the size of an element in tuple faster then list. Also finding element by index is fast in tuple.

     

    So in this short tutorial, I am showing you how you can Update tuple in Python

    Below example, you can see that we have 2 tuples tuple1 and tuple2 so for updating tuple we created a variable named tuple3:

    tuple1 = (10, 30.16);
    tuple2 = ('abcd', 'xyzp);
    
    #Now i have to create new tupples as follows:
    tuple3 = tuple1+tuple2
     print tuple3
    

     

    Output:

    (10, 30.16, 'abcd', 'xyzp')

     

    How to Update Tuples in Python Programming Language
    Updating Tuples in python tuple

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: