Simple String Code In Python

Introduction

 
In this blog, I will be explaining about simple strings in Python. We will use them to add names and delete names in the string.
 
Software Required
 
Python 2.7.11
 
Programming
  1. names=['karthiga','c#corner','MVP','Monthly Winner','Author'];  
  2. print(names);  
  3. print(names[1]);  
  4. del names[0];  
  5. print(names);  

Explanation

 
First Name in the String
  1. names=['karthiga','c#corner','MVP','Monthly Winner','Author'];  
  2. print(names);  
  3. 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
 
Output
 
Figure 1:Output 
 
Delete Name in the String: 
  1. del names[0];  
  2. 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
 
Output
 
Next Recommended Reading Simple Stopwatch Using Python