-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrings.py
More file actions
41 lines (31 loc) · 770 Bytes
/
Strings.py
File metadata and controls
41 lines (31 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
my_string='Hello'
print(my_string)
my_string="Hello"
print(my_string)
my_string='''Hello'''
print(my_string)
my_string="""Hello,welcome to
the world of Python"""
print(my_string)
str='programiz'
print('str=',str)
#first character
print('str[0]=',str[0])
#last character
print('str[-1]=',str[-1])
#slicing 2nd to 5th character
print('str[1:5]=',str[1:5])
#slicing 6th to 2nd last character
print('str[5:-2]=',str[5:-2])
str1='Hello'
str2='World'
print('str1+str2=',str1+str2)
print('str1*3=',str*3)
count=0
for letter in 'Hello World':
if(letter=='l'):
count+=1
print(count,'letters found')
print('''He said,"Whats's there?"''')
print('He said,"What\'s there?"')
print("He said, \"What's there?\"")