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 ▸

Why would I use dictionaries instead of a list?


Write a simple number guessing game, give the user 3 tries to guess a number between 1 and 10


Describe both For-loops and While-loops and explain how you can simulate the effect of a for loop with a while loop with an example.


Write a python function that takes a string as parameter and returns the character in the string with the most occurrences, along with the number of times this character occurs