Dear Info-Team,
I run into problems running this example file under python 3.8.2 under MS-Windows 10.
Error message for both:
"
Strategy: Iterate over copy of collection
"
"
Strategy: Create a new collectio"
>>> AttributeError: 'list' object has no attribute 'items'
###########################################################################
#!"C:/Program Files/Python38/python3.exe"
### Tutorial examples (taken from the "official" Tutorial by Python team
### Tested under IDLE of Python 3.8.2
# Iterate over a collection
users = ['Hans', 'Andrea', 'inactive', 'Nils']
for w in users:
print('w: ', w, ', \tlen(w): ', len(w), '.')
# Strategy: Iterate over copy of collection
for user, status in users.copy().items():
if status == 'inactive':
del users[user]
print('user: ', user, ', users[user]: ', users[user])
# Strategy: Create a new collection
active_users = {}
for user, status in users.items():
if status == 'active':
active_users[user] = status
# end
###########################################################################
Do you have some advice? Could you add additional information to the Tutorial-PDF?
Regards,
Stefan
--
Stefan Pofahl
Zollgasse 5
8020 Graz
Österreich
Tel.: +43 (316) 33 2001