22
33## String
44* String is a sequence of characters.
5- * We have seen the string representation in previous chaptor .
5+ * We have seen the string representation in previous chapter .
66* Python provides lots of built in method associated with it.
77
88### Side by side string literals
7373>>>
7474```
7575
76- ### Strip some characters from a strin
76+ ### Strip some characters from a string
7777```
7878>>> a = "abc\n"
7979>>> a.strip() # It will remove new line
989820
9999```
100100### String Indexing
101- * First character of a string has index 0 .
102- * Negative indices start form -1 , when counted from right.
101+ * First character of a string has index ` 0 ` .
102+ * Negative indices start form ` -1 ` , when counted from right.
103103```
104104>>> word = "Welcome to FOSS MEET"
105105>>> word[0]
113113```
114114
115115### String Slicing
116- * string[ x: y ] -> returns the string starting from index x to y-1.
116+ * ` string[x:y] ` returns the string starting from index ` x ` to ` y-1 ` .
117117```
118118>>> word[2:8]
119119'lcome '
@@ -132,7 +132,7 @@ TypeError: 'str' object does not support item assignment
132132
133133## List
134134* Comma separated values between square brackets
135- * List can be sliced, indexed and cancatenated
135+ * List can be sliced, indexed and concatenated
136136* Lists are mutable it means we can append and remove items from a list.
137137```
138138>>> a = [1,2,3,4,5,6]
@@ -193,8 +193,8 @@ which follow it.
193193```
194194
195195## Tuples
196- * Items seperated by comma in a closed bracket.
197- * These are immutables it means we cannot append or remove date from it.
196+ * Items separated by comma in a closed bracket.
197+ * These are immutable, it means we cannot append or remove data from it.
198198```
199199>>> a = (1,2,3,'hello')
200200>>> a
@@ -227,14 +227,14 @@ TypeError: 'tuple' object doesn't support item deletion
227227```
228228
229229## Set
230- A list of items with no duplicates in curlie braces.
230+ A list of items with no duplicates in curly braces.
231231```
232232>>> a = 'axbecjnn2226'
233233>>> set(a)
234234{'n', 'e', 'a', '6', 'x', 'b', 'j', '2', 'c'}
235235>>>
236236```
237- * Define another set b and try out a -b , a | b, a & b, a ^ b
237+ * Define another set ` b ` and try out ` a - b ` , ` a | b ` , ` a & b ` , ` a ^ b `
238238* We can also add and remove values from set
239239```
240240>>> c
@@ -247,12 +247,11 @@ A list of items with no duplicates in curlie braces.
247247```
248248
249249## Dictionaries
250- * Unordered set of key: value pairs under {} braces where keys are unique
250+ * Unordered set of key: value pairs under ` {} ` braces.
251251* Keys are unique in nature.
252- * Dictionaries are mutable buts keys are immutable
253- * By using particular Keys, we can updat the value.
254- * Values can be numbers, string, list, or tuples.
255- * We can access valuing dictionary.
252+ * Dictionaries are mutable but keys must be of immutable type.
253+ * By using particular key, we can access or update the value.
254+ * Values can be of any data type.
256255```
257256>>> mydict = {'number': 1, 'letter': 'foobar', 'mytuple':(1,2,3), 'foobar': [1,2,3,4]}
258257>>> mydict
@@ -278,10 +277,10 @@ True
278277>>> len(mydict)
2792784
280279```
281- We can always run a loop over list, string, tuples and dict:
280+ We can always run a loop over list, string, tuple and dict:
282281
283282### Fun time
284- * Create a dictionary which has keys like numbers, strings, tuples, list, set and dict and put some value.
283+ * Create a dictionary which has keys like numbers, strings, tuples, list, set and dict and put some value.
285284 Run a for loop and print their data types and their content.
286285
287286* Checkout lambda and map function
0 commit comments