0% found this document useful (0 votes)
4 views1 page

15

Uploaded by

kumar108
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

15

Uploaded by

kumar108
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

5

3. print (str1[0:2]) #printing first two character using slice operato


r
4. print (str1[4]) #printing 4th character of the string
5. print (str1*2) #printing the string twice
6. print (str1 + str2) #printing the concatenation of str1 and str2
Output:
he
o
hello javatpointhello javatpoint
hello javatpoint how are you

List
Lists in Python are like arrays in C, but lists can contain data of
different types. The things put away in the rundown are isolated
with a comma (,) and encased inside square sections [].
To gain access to the list's data, we can use slice [:] operators.
Like how they worked with strings, the list is handled by the
concatenation operator (+) and the repetition operator (*).
Look at the following example.
Example:
1. list1 = [1, "hi", "Python", 2]
2. #Checking type of given list
3. print(type(list1))
4.
5. #Printing the list1
6. print (list1)
7.

You might also like