Skip to main content

Posts

Showing posts from May, 2021

Python classes to Ammu

Python uses dynamic typing, meaning you can reassign variables to different data types. This makes Python very flexible in assigning data types; it differs from other languages that are statically typed. We can use a colon(:) to perform slicing which grabs everything up to a designated point. s='Hello world' print(s[:5])=Hello we can use two colons in a row and then a number specifying the frequency to grab elements. For example: s[::2] 'HloWrd' s[::3] 'Hlwl' s[::-1] 'dlroW olleH' .split() is a Built in string method used to split the string, by default it takes the blank spaces s='please split this function' s.split() ['please','split','this','function'] Split by a specific element by using that letter s.split('f') ['please split this', 'unction'] We can use the .format() method to add formatted objects to printed string statements. print('Insert another string...