[Python] How do you extract part of a numeric tuple with Python

Discussão em 'Python' iniciado por Stack, Maio 28, 2025.

  1. Stack

    Stack Membro Participativo

    I am stuck on one exercise to extract the lat lon from a tuple and print lat lon on separate lines.

    nyc_data = {'city': 'New York', 'population': 8175133, 'coordinates': (40.661, -73.944) }
    print(nyc_data['coordinates'])


    which produces

    (40.661, -73.944)


    I assigned 'New York' to a variable and was able to slice 'New' but when I tried this on a numeric value it only reproduces the whole number. How do you slice a numeric value in a tuple?

    Continue reading...

Compartilhe esta Página