English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Méthodes de collections en Python
The clear() method removes all elements from the set.
The syntax of the clear() method is:
set.clear()
The clear() method does not take any parameters.
The clear() method does not return any value and returns'None'.
# Set vowels = {'a', 'e', 'i', 'o', 'u'} print('Vowels (before clearing):', vowels) # Clear vowels vowels.clear() print('Vowels (after clearing):', vowels)
When running the program, the output is:
Vowels (before clearing): {'o', 'i', 'e', 'u', 'a'} Vowels (after clearing): set()