Treating A String Like A List, In Python

Introduction

 
In this blog, we will discuss how to treat a string like a list, in Python.The output will display in the Run module.
 
Software Requirement
 
Python 3.5.2
 
Simple Programming
  1. print("Welcome To C#Corner..........")  
  2. print("Treating String Like A List :")  
  3.   
  4. names=["C#Corner","MVP","Author","Member Of Month"]  
  5. print("%s" % names[0])  
  6. print("%s" % names[0][0],"%s" % names[1][0])  
  7. print("%s" % names[2],"%s" % names[3])  
Explanation
 
In the above code, we are giving the string. And, using the print() function, we can get the strings as list, as shown below. The output can be seen in the Run Module.
 
Output
 
Output