Tag Archives: basic string in python

Python- The Strings

Strings in Python can be created by enclosing characters in either single quotes ‘example ‘  or in double quotes “example”

It’s easy to declare a string as shown below:

str1 = ‘hello world’

str2 =  “hello world”

 

 

To concatenate two strings we can use the ‘+’  operator

 

 

You can use brackets for slicing the string between indexes:

 

When you run the final program, you should get the output as below:

Advertisements