STRINGS
,COMPOUND DATA TYPE
• Strings are qualitatively different from Integer and Float type.
• Characters which collectively form a String is a Compound Data Typ
For Eg.
fruit = “apple”
letter = fruit[1]
print (letter)
Output : p // (index value starts from 0 as in C & C++)
, LENGTH OF STRINGS
• The inbuilt function to find the length of a string is ‘len()’.
For Eg.
fruit = “banana”
len(fruit)
Output : 6
• To get the last letter we might try
length = len(fruit)
last = fruit[length] #ERROR
( because there is no character at 6th place)
,COMPOUND DATA TYPE
• Strings are qualitatively different from Integer and Float type.
• Characters which collectively form a String is a Compound Data Typ
For Eg.
fruit = “apple”
letter = fruit[1]
print (letter)
Output : p // (index value starts from 0 as in C & C++)
, LENGTH OF STRINGS
• The inbuilt function to find the length of a string is ‘len()’.
For Eg.
fruit = “banana”
len(fruit)
Output : 6
• To get the last letter we might try
length = len(fruit)
last = fruit[length] #ERROR
( because there is no character at 6th place)