Listing 08-25: Navigating lists based on the type of their elements

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 08\08.25 - Navigating lists based on the type of their elements.py
# Description: Navigating lists based on the type of their elements
##############################################################################

L = ["a", ["b", "c", "d"], "e"]
for x in L:
    if type(x) is str:
        print(x)
    else:
        print("List:", end= "")
        for z in x:
            print(f" {z}", end= "")
        print()
Click here to download the file