Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- py = "python & python"
- welcome = 'welcome'
- # the way of string concat
- print( 'concat: '+ py + ( ' is the most powerful language' ) )
- # find the length
- len = str( len( py ) ) # convert int to string
- print( 'length: the length of python is: ' + len )
- # get the characters
- print( '0 to 5 elements are in python: ' + py[ 0 : 5 ] )
- # or print( '0 to 5 elements are in python: ' + py[ : 5 ] )
- # uppercase,lowercase
- print( 'In uppercase: in uppercase python is: ' + py.upper() )
- # find the number of words or chars
- print( 'Count: there are: '+ str( py.count('python') ) + ' times' )
- # replace
- repl = py.replace('& python', '')
- print( 'replace: ' + repl + ' is the most powerful language' )
- # more at code no. 56
- #format
- formatt = '{} to {}'.format(welcome,py)
- print('format: ' + formatt)
- # help
- # print( help(str) )
- # debug ctrl+F5
Advertisement
Add Comment
Please, Sign In to add comment