Introduction
In this blog, I will be explaining about simple strings in Python. We will use them to add name and delete name in the string.
Software Required
Python 2.7.11
Programming
- names=['karthiga','c#corner','MVP','Monthly Winner','Author'];
- print(names);
- print(names[1]);
- del names[0];
- print(names);
Explanation
First Name in the String
- names=['karthiga','c#corner','MVP','Monthly Winner','Author'];
- print(names);
- print(names[1]);
This code can be used to display the single name in the Run module. Here, I gave the number of a name (starting from 0) in the code and we can see that in the output, that name at number 1 has been displayed.
Output
Figure 1:Output
Delete Name in the String:
- del names[0];
- print(names);
This is the code that we use to delete a name in a string. Here also, we can define a number according to what name we want to delete. I used number 0 and we can see that the name at position 0 has been deleted from the output in the Run module.
Output