Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Concatenating Tuples in Python: Merging Immutable Sequences | Mastering Python Tuples
Python Data Structures
course content

Kursinnhold

Python Data Structures

Python Data Structures

2. Mastering Python Dictionaries
3. Mastering Python Tuples
4. Mastering Python Sets

book
Concatenating Tuples in Python: Merging Immutable Sequences

In Python, it's possible to combine tuples. This involves forming a new tuple by merging two or more existing ones. You can accomplish this with the + operator. Here's an example to illustrate.

1234567
movie_titles = ("Inception", "Interstellar", "Dunkirk") release_years = (2010, 2014, 2017) # Concatenate the tuples combined_tuple = movie_titles + release_years print(combined_tuple)
copy
Oppgave

Swipe to start coding

You are given: the tuple space_movies and the list new_movies.

  • Convert the list into a tuple and assign the result to the variable animal_movies.
  • Use the tuple function to complete the first step.
  • Concatenate the two tuples and assign the result to the variable movie_poster.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 3
toggle bottom row

book
Concatenating Tuples in Python: Merging Immutable Sequences

In Python, it's possible to combine tuples. This involves forming a new tuple by merging two or more existing ones. You can accomplish this with the + operator. Here's an example to illustrate.

1234567
movie_titles = ("Inception", "Interstellar", "Dunkirk") release_years = (2010, 2014, 2017) # Concatenate the tuples combined_tuple = movie_titles + release_years print(combined_tuple)
copy
Oppgave

Swipe to start coding

You are given: the tuple space_movies and the list new_movies.

  • Convert the list into a tuple and assign the result to the variable animal_movies.
  • Use the tuple function to complete the first step.
  • Concatenate the two tuples and assign the result to the variable movie_poster.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 3
Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Vi beklager at noe gikk galt. Hva skjedde?
some-alt