Concatenation of Tuples and Lists

Lesson Details:
September 17, 2020

Video Transcription: In this lecture I am going to talk about concatenation of tuples so let me give the commands concatenation of two tuples this video is brought to you by Appy Pie’s Academy, as you know concatenation means joining together so will be joining a tuple with another tuple and even we can join a list with the tuple also so let's understand it with the help of examples values one is going to be a tuple values 1 is equal to I am giving some values 10 20 30 40 50 okay this is our tuple and I am going to have another tuple with the name values 2 and what I am going to do is I am going to go for concatenation so what I will do is I would write values 1 comma 100 200 300 400 something and 400 comma 500 okay so the concatenation will take place and the output will be stored into the tuple values 2 so now what will happen is all the items of values one like 10 20 30 40 50 they will be merged with this tuple value 100 200 300 400 500 and after merger the values will be put into values - okay so let's execute this program now I will see the output like this yes you can see 10 20 30 40 50 and after that the next tuple 100 200 300 450 these items they have been merged together so it's an important this is something important to learn now next we are going to learn we are going to a list so I will show you we can concatenate a list also so as you know where I will give the items of a list we people use square brackets and not parentheses this is a list not a tuple okay so now I am going to take a tuple with the name let it be values 3 this is the name of the tuple and what I am going to do is let me write this thing I will give some values one twenty two thirty four fifty something or you can give any values twelve hundred twenty three hundred forty five hundred any values so this is what you pull and after that what I am going to write as gamma my list as you know my list is the name of the list and after that I will get the value of values three printed so the values of these items twelve hundred twenty three hundred forty five hundred they will be merged with my list values that is 900 1000 1112 order so it's better that we give a heading so that we are able to distant use the outputs following are the values of Cuba values 3 okay so now let's go and execute the program yeah this is the appropriate place so I will execute the program now we will see the merger of yes this is we now we will see the merger of the list with the tuple so you can see the output twelve hundred twenty three hundred forty five hundred nine hundred one thousand 1,100 1,200 last three four values they belong to the list my list so concatenation of a tuple and a list has taken place okay we can also concatenate two tuples or less using plus symbol has you know plus symbol s stack that stands for concatenation so this is also possible let me show you an example I am going to take a tuple one values are going to be one two three four five okay another tuple with the name two six seven eight nine ten or whatever values you want to give okay so now what I am going to do is I would write two value of four tuple six seven eight nine ten plus one so as you know as you know one is another tuple that is going to be merged so let me give the comment here also so I will copy pasted and I will change the message now I would write following are the values of tuple two so in the tuple 2 what will happen is the tuple 6 7 8 9 10 and the tuple 1 they will be merged together concatenated and put into to yes you can see the result 6 7 8 9 let's go to the bottom 6 7 8 9 10 1 2 3 4 5 so the tuple 6 7 8 9 10 that was mentioned first that is why the sequences like this or you can do the other way around what you can do is you can write one six seven eight nine ten so six seven eight nine ten this tuple will be merged with the tuple one so values of the tuple one will come first okay yeah now the values of the people one they are appearing first one two three four five and then six seven eight nine ten this is appearing so it's quite simple to concatenate two tuples or one tuple and one list.

loader
Course content