Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre L'Instruction Else dans une Boucle For | La Boucle For
Tutoriel sur les Boucles en Python
course content

Contenu du cours

Tutoriel sur les Boucles en Python

Tutoriel sur les Boucles en Python

1. La Boucle For
2. La Boucle While
3. Boucles Imbriquées
4. Compréhensions de Listes et de Dictionnaires

book
L'Instruction Else dans une Boucle For

1234567
travel_list = ['Monako', 'Luxemburg', 'Liverpool', 'Barcelona', 'Munchen'] # Printing all destinations for city in travel_list: print(city) else: print('All destinations have been listed.')
copy
123456789
travel_list = ['Monako', 'Luxemburg', 'Liverpool', 'Barcelona', 'Munchen'] # Searching for a specific city for city in travel_list: print(city) if city == 'Barcelona': break else: print('All destinations have been listed.')
copy
123456789
travel_list = ['Monako', 'Luxemburg', 'Liverpool', 'Barcelona', 'Munchen'] # Checking if a city is NOT in the list search_city = 'Paris' if search_city not in travel_list: print(search_city, 'is not in the travel list.') else: print(search_city, 'is in the travel list.')
copy
question mark

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 5

Demandez à l'IA

expand
ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

course content

Contenu du cours

Tutoriel sur les Boucles en Python

Tutoriel sur les Boucles en Python

1. La Boucle For
2. La Boucle While
3. Boucles Imbriquées
4. Compréhensions de Listes et de Dictionnaires

book
L'Instruction Else dans une Boucle For

1234567
travel_list = ['Monako', 'Luxemburg', 'Liverpool', 'Barcelona', 'Munchen'] # Printing all destinations for city in travel_list: print(city) else: print('All destinations have been listed.')
copy
123456789
travel_list = ['Monako', 'Luxemburg', 'Liverpool', 'Barcelona', 'Munchen'] # Searching for a specific city for city in travel_list: print(city) if city == 'Barcelona': break else: print('All destinations have been listed.')
copy
123456789
travel_list = ['Monako', 'Luxemburg', 'Liverpool', 'Barcelona', 'Munchen'] # Checking if a city is NOT in the list search_city = 'Paris' if search_city not in travel_list: print(search_city, 'is not in the travel list.') else: print(search_city, 'is in the travel list.')
copy
question mark

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 5
Nous sommes désolés de vous informer que quelque chose s'est mal passé. Qu'est-il arrivé ?
some-alt