fruits_dic={'apple':6000,'melon':3000,'banana':5000,'orange':7000}
fruits_dic.clear()
print(fruits_dic)
Result value
{}
-------------------------------------------------
fruits_dic={'apple':6000,'melon':3000,'banana':5000,'orange':7000}
print(fruits_dic.clear())
Result value
None
I wonder why the two results are different!
python dictionary method
This is because the clear command is not a command to spit out the result value.
fruits_dic={'apple':6000,'melon':3000,'banana':5000,'orange':7000}
a = fruits_dic.clear()
print(a)
print(fruits_dic)
>> None
{}
fruits_dic={'apple':6000,'melon':3000,'banana':5000,'orange':7000}
print(fruits_dic.clear())
print(fruits_dic)
>> None
{}
© 2024 OneMinuteCode. All rights reserved.