Data Type Of Python I n the last session we discus about what is the data type of python. And we see List data type. In this session we s ee the next data type String. 2) String- String is a ordered collection of immutable data type. String are iterable and hashable. Strings are always declared in single or double quotes. Single line string:- S = "Python" Multi line string:- S = """ Line 1 Line 2 Line 3 """ Iterable:- S= "Program" for i in S: print(i) Output:- P r o g r a m Membership:- print( 'p' in S) => True print( 'P' not in S) => False Methods of string:- capitalize() :- It return the capitalize version of the string. More specifically it make the first character have uppercase and rest lowercase. For example:- S = "hello World" print(S.capitalize()) => "Hello world" count(substring, start,en...
Comments
Post a Comment