What are mutable and immutable types in Python?

Question

Can you help me with this question

 

Answer ( 1 )

    0
    2025-02-26T02:35:16+00:00
    • Mutable (can be changed): list, dict, set
    • Immutable (cannot be changed): int, float, str, tuple

    Example:

    x = “hello”
    x[0] = “H” # ❌ TypeError (immutable)

Leave an answer