Posts

Python String

Image
A string represents the group of characters. String are important because most of the data we use in daily life will be in the form of string. Example: name of the person, the address etc. In python str datatype represents a string. Since every string comprises several characters, python handles string and characters almost the same manner. There is no separate datatype to represent individual characters in python. Creating Strings We can create a string in python by assigning a group of characters to a variable. The group of characters should be enclosed inside single, double or triple quotes as shown in an example: S1= ‘Welcome to pythonior.com’ S2= “Welcome to pythonior.com” S3=“‘Welcome to pythonior.com”’ It is possible to display quotation marks to mark a substring in a string.  In this case you should use one type of quotes for outer string and another type of quotes for inner string as: S1 =  ‘ welcome to “ python” tutorial’ ...

Python List

We have already seen What List is? and how to write elements in List. To follow that post visit Python Data Types . Where you will get all the different data types available into Python programming. In this blog we will see different methods to work on list, this can be like appending a item to list, removing item from list, How to find length of a list and so on.... What is Method? Method is basically a function which is written for specific object.  Syntax: name_of_an_object . name_of_the_method example: x = [2,5,3,8,6,9] x.sort ( ) Here you can see x is the object of type 'List' and sort is the method to perform on object. Below given is the list of methods that can be executed on list type of object. We will see each one with an example. list.append(x) Add an item to the end of the list. Equivalent to a[len(a):] = [x]. list.extend(L) Extend the list by appending all the items in the given list. Equivalent to a[len(a):] = L. list.inse...