Python: default argument blunders

A few minutes ago a friend sent me the following code, and told me its misbehaving: def foo(l=[]): l.append(“hello!”) print(l) foo() foo() Instead of printing [“hello”] twice, it printed [“hello”, “hello”]. Any ideas why? what’s going on? I’ll… Read more

Similar

Habits for Effective Python Learning [video]

When learning a programming language, how do you know whether the effort you're putting in is working or whether you're wasting your time?We'll be chatting with Michael Herman and Evan Moore about tec - Watch Trey Hunner's recorded Crowdcast - Sat Mar 11 ... (more…)

Read more »