How do I use format python code?

You should beware of indentation in your code as indentation will affect how the code runs and can prevent you from being able to compile your code. It can also create logic errors, producing results which you didn't expect to receive. Make sure you code things in the right order, for example initialise variables before you use them. Also make sure to import modules which you may need to use at the start of your program. Apart from that, there is no special format needed to start off code unlike in other languages such as C or Java.

CL

Related Python Mentoring answers

All answers ▸

how to compute the factorial of a number.


Write a simple Python program that asks a user to input their age and name and then return the text: "Hi my name is *NAME*, and I am *AGE* years old."


How do you write code to implement a recursive fibonacci algorithm?


Explain why creating a list of several instances of one element using something like my_list = [a] * 5 can result in strange behaviour