Python string to int
Python string can be converted to int using int(strval). Note that it will throw ValueError for invalid string. Here is a quick example to convert read more
Python int to string
Python int (or any other data type like float) needs to be converted to string before we can do concatenation operation using plus (+). It read more
Python dictionary basics
Python dictionary (associative arrays) – some basic operations. Initialize dictionary Check if a key exists access value for a key list length/size using len() len() read more
Python type – find type of a variable
Python in-built function type() can be use to find type of any variable or value. Example – type() of string variable Example – type() of read more
Python initialize large list with same value
To initialize a large list with same value (all items having same value), the following syntax can be used. a = [val] * num_items Example
Python array slice
Slicing a list (array) in python is very handy way to get a sub list of an array. Its syntax is ## slice from start read more
Python list/array – remove an item
To remove an item from python list method pop([i]) can be used. Remove last item Remove first item Remove ith item
Python list – append or prepend a value
Appending or prepending a value to a list in Python. Append value Prepend value
Python list (array) basics
Python list (or array) – some basic operations. Initialize list access ith item access last item list length/size using len() Note than len() can also read more
Python string contains check
To check if a string is part of another string (case sensitive) we can use these approaches Using in operator Using string find() method ## read more