We have covered Python Data Types and Loops in Python earlier. Hope you find them useful. Moving ahead with our Python learning, in this article we are going to talk about the top 15 interesting tricks every Python beginner must know. First of all, let us understand about Functions and Methods. Function – A Function is an independent block of code that can be called by its name with or without any parameter. We can create a function that does or does not return any value as an output. Method – All methods are functions associated with an object of the class in which it is defined. Now we will explain various Functions and Methods related to Strings and Lists along with some examples. Python in String related Functions & Methods – Title() – This method can be used to convert the first letter of the words in a string to its upper case. We can get a look at the way we write the title of any article. a = "corona virus spreads throughout the planet" a.title() Swapcase() – As the name suggests, this method is to convert the uppercase letter to lower case and vice versa. a = "cORONA vIRUS sPREADS throughout the planet" a.swapcase() Split() – We can use the split […]
The post Top 15 Interesting Tricks Every Python Beginner Must Know appeared first on Ivy Professional School | Official Blog.