Can someone explain why these two different code samples give different outputs? I'm confused on why the first sample appends "sunny" and "cloud" to all months, which is not what I want. I want the output of the second sample. However, I want to assign the variable "forecast", not its value to weatherReport["months"][month]. Is there a way to get the output of Sample 2 this way?

In second code, you assign a brand new independant list for each month. So when you later append values to those lists, you append only to the proper list.

In first code, you assign the same variable to each month. In Python it means that each month has a reference to same list. So when you add a value to any of those list, in reality you add it to the forecast list, to which each month points. So the result.

Under the hood the cause is that a list is mutable, that means that you can modify an object which other objects point to. You will not be able to reproduce that with non mutable objects like strings.