0% found this document useful (0 votes)
11 views2 pages

Comparison of List, String, Tuple, Dictionary Methods

The document provides a comprehensive comparison of methods applicable to lists, strings, tuples, and dictionaries in programming. It details various methods, their input types, and descriptions of their functionalities. Each method is marked with a check or dash to indicate its applicability to the respective data types.

Uploaded by

carifor770
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Comparison of List, String, Tuple, Dictionary Methods

The document provides a comprehensive comparison of methods applicable to lists, strings, tuples, and dictionaries in programming. It details various methods, their input types, and descriptions of their functionalities. Each method is marked with a check or dash to indicate its applicability to the respective data types.

Uploaded by

carifor770
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Full Comparison of Methods for List, String, Tuple,

and Dictionary
Method List String Tuple Dictionary Input Type Description
append() ✔ - - - value Adds element at the end of list

extend() ✔ - - - iterable Appends elements from another iterable

insert() ✔ - - - index, value Inserts element at given index

remove() ✔ - - - value Removes first occurrence of element

pop() ✔ - - ✔ index (optional for list), key(for dict) Removes element at index (list) or key (dict)

clear() ✔ - - ✔ none Removes all elements

index() ✔ ✔ ✔ - value Returns index of first occurrence

count() ✔ ✔ ✔ - value Counts number of occurrences

sort() ✔ - - - none or key function Sorts list in ascending order

reverse() ✔ - - - none Reverses list in place

copy() ✔ - - ✔ none Returns shallow copy

capitalize() - ✔ - - none Capitalizes first character

casefold() - ✔ - - none Converts string to lowercase (more aggressive than lower)

center() - ✔ - - width, fillchar(optional) Centers string with padding

encode() - ✔ - - encoding(optional) Returns encoded string

format() - ✔ - - values Formats string

isalpha() - ✔ - - none Checks if all chars are alphabetic

isdigit() - ✔ - - none Checks if all chars are digits

isalnum() - ✔ - - none Checks if all chars are alphanumeric

islower() - ✔ - - none Checks if all chars are lowercase

isupper() - ✔ - - none Checks if all chars are uppercase

isspace() - ✔ - - none Checks if all chars are whitespace

istitle() - ✔ - - none Checks if string is titlecased

split() - ✔ - - separator(optional) Splits string into list

rsplit() - ✔ - - separator(optional) Splits string from the right

strip() - ✔ - - chars(optional) Removes leading/trailing characters

lstrip() - ✔ - - chars(optional) Removes leading characters

rstrip() - ✔ - - chars(optional) Removes trailing characters

replace() - ✔ - - old, new Replaces substring with another

upper() - ✔ - - none Converts to uppercase

lower() - ✔ - - none Converts to lowercase

startswith() - ✔ - - prefix Checks if string starts with prefix

endswith() - ✔ - - suffix Checks if string ends with suffix


Method List String Tuple Dictionary Input Type Description
find() - ✔ - - substring Returns lowest index of substring

rfind() - ✔ - - substring Returns highest index of substring

partition() - ✔ - - separator Splits into 3 parts: before, separator, after

rpartition() - ✔ - - separator Splits into 3 parts from the right

swapcase() - ✔ - - none Swaps case of all characters

title() - ✔ - - none Converts string to title case

zfill() - ✔ - - width Fills string with zeros at the beginning

count() - - ✔ - value Counts number of occurrences

index() - - ✔ - value Returns index of first occurrence

get() - - - ✔ key Returns value for key, or None

keys() - - - ✔ none Returns all keys

values() - - - ✔ none Returns all values

items() - - - ✔ none Returns key-value pairs

update() - - - ✔ dict or iterable Updates dictionary with given pairs

fromkeys() - - - ✔ keys, value(optional) Creates new dict with given keys

setdefault() - - - ✔ key, default(optional) Returns value if key exists, else inserts default

popitem() - - - ✔ none Removes and returns last inserted key-value pair

You might also like