0
Can we use the method of string in list and dictionary vice versa?
2 Réponses
+ 3
Do you mean you want to use the methods available in the `str` type in `list` and `dict`? If yes, then no, you can't. There is reason those methods are in the `str` type. Imagine calling .isdigit() method on a list or dict.
+ 1
There are some functions that applies to multiple data structures, one of them is 'len' , 'del' etc.. But I dont think you can use a function of string (only to string) to another data structure vice versa
For more info, you can visit these links. They also gives examples.
https://docs.python.org/3/tutorial/datastructures.html
Tuples
https://www.w3schools.com/python/python_tuples.asp
List
https://www.w3schools.com/python/python_lists.asp
Dictionary
https://www.w3schools.com/python/python_dictionaries.asp
Sets
https://www.w3schools.com/python/python_sets.asp