[Python] I am a new learner of Python, and I am having a major problem with my code [closed]

Discussão em 'Python' iniciado por Stack, Agosto 31, 2025.

  1. Stack

    Stack Membro Participativo

    The problem can be summarized below in this snippet of code.

    #! python3

    people = {
    "alice": {
    "style": "bun",
    "length": 5},
    "bob":{
    "style": "ponytail",
    "length": 19}
    }
    cut = people["alice"["length"]] =+ 1
    print("Alice's hair length is" + str(cut))



    I tried adding and taking away the quotation marks around "alice" and "length" and using the .get() function, among other things, trying to get it to read (in this example) "Alice's hair length is 20". Instead I got a variety of syntax errors and "TypeError: String indices must be integers", depending on what I tried.

    Continue reading...

Compartilhe esta Página