I am trying to print a dictionary value after deleting few key-value. Below code works in Pycharm but throwing error when i execute the same in IDLE it throws error. please, guide.
**users={'John':'Active',
'Joseph':'Inactive',
'Reeta':'Inactive'}
for del_user, status in users.copy().items():
if status=='Inactive':
del users[del_user]
print(del_user)
print(users) **
>Solution :
users={'John':'Active',
'Joseph':'Inactive',
'Reeta':'Inactive'}
for del_user, status in users.copy().items():
if status=='Inactive':
del users[del_user]
print(del_user)
print(users)
Above code is working fine on IDLE.
Crosscheck that you are giving proper indentation and not adding **.
If might cause if you copy the code from somewhere.