-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparsing.py
37 lines (27 loc) · 1.13 KB
/
parsing.py
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
# Index starts from 0
list1 = [1 ,5 ,10.0 , "python","ok"]
str = "python"
tuple1 = (10,50,"String1",100.0,"Hello")
# parsing and changing list
print("\nParsing and changing value of list")
for i in list1:
print ("The value in list1 is : ",i)
print("The value of the 3rd index in the list is : ",list1[3])
print("The value of the -1 index in the list is : ",list1[-1])
print("Before Changing the value of list : ",list1)
list1[1] = 1212 #changed the value of 1st index of the list to 1212
print("After Changing the value of list : ",list1)
# Parsing and changing string
print("\nParsing and changing value of string")
for i in str:
print ("The character of the string is ",i)
print("The value of the 3rd index in the string is : ",str[3])
print("Before Changing the value of string : ",str)
str = "Hello World"#changed the value of str to hello world
print("After Changing the value of string : ",str)
# Parsing the tuple
print("\nParsing the value of tuple")
for i in list1:
print ("The value in tuple1 is : ",i)
print("The value of the 3rd index in the tulpe is : ",tuple1[3])
print("The value of the -1 index in the tuple is : ",tuple1[-1])