Repository navigation
Expand file tree
/
Copy path7_Day_1_Strings_Methods.py
More file actions
113 lines (71 loc) · 2.86 KB
/
Copy path7_Day_1_Strings_Methods.py
File metadata and controls
113 lines (71 loc) · 2.86 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# STRINGS Methods
# #Example 1. Removing Spacea from Leading and trailing
# Text=" Hello learners Python "
# print("Original Text :",Text)
# print("Remove Spaces output : ",Text.strip())
#Eaxmple 2. Upper Letters
# Text=" Hello learners Python "
# print("Original Text :",Text)
# print("Remove Spaces output : ",Text.strip())
# print("Upper Letter output:",Text.upper())
#Here we used strip function otherwise it leading and trailing space is remain same as pe the
# Text=" Hello learners Python "
# print("Original Text :",Text)
# print("Upper Letter output:",Text.upper().strip())
# #or
# Text=" Hello learners Python "
# print("Original Text :",Text)
# print("Upper Letter output:",Text.upper()
# .strip())
# strip = All Space from left and right removing.
# rsrtip = Space from right side removing.
# lstrip = Space from left side removing.
#Eaxmple 3. Proper Letters
# Text=" hello python learners "
# print("Original Text :",Text)
# print("Upper Letter output:",Text.title()
# .strip())
#Eaxmple 4. Lowers Letters
# Text=" Hello Python Learners "
# print("Original Text :",Text)
# print("Upper Letter output:",Text.lower()
# .strip())
# #Eaxmple 5. replace Word
# Text=" Hello Python Learners "
# print("Original Text :",Text)
# print("Replace Python Word by SQL:",Text.replace("Python","SQL")
# .strip())
# #Eaxmple 6.Count occurance of word
# Text=" Hello Python Learners "
# print("Original Text :",Text)
# print("Replace Python Word by SQL:",Text.replace("Python","SQL")
# .strip())
# print("Count of O is:",Text.count("o"))
# #Eaxmple 7.Start with some Word
# Text=" Hello Python Learners "
# print("Original Text :",Text)
# print("Replace Python Word by SQL:",Text.replace("Python","SQL")
# .strip())
# print("Count of O is:",Text.count("o"))
# print("Start with Word ?:",Text.strip().startswith("Hello")) #Here we used strip function to remove space before the word.
# # #Eaxmple 8.Data is Numeric
# mobile="9823565726"
# print("Data is numeric ?:",mobile.isnumeric())
# mobile1=" Masters in data science"
# print("Data is numeric ?:",mobile1.isnumeric())
# #Eaxmple 9.Split function used
# Word="Welcome to goa Sinhgam"
# print("Word is as per following:",Word.split())
# Joined_Text="".join(Word)
# print("Joined Texts:",Joined_Text)
# # #Eaxmple 10.Joined back with hyphen
# Word="Welcome to goa Sinhgam"
# Joined_Text="".join(Word)
# print("Joined Texts:",Joined_Text)
# ## Example .11 finding position of g
# Word="Welcome to goa Sinhgam"
# print("Find the position of g :",Word.find("g"))
## Example .12 Extract diomain
email="student@example.com"
domain = email[email.find("@")+1:]
print=("The domain Name is:",domain)