Python %

so i am learning myself python (i also know html and css, and a small bit of php)
and i just got started and got stuck on what this does % i searched but i am not a native english speaker and i still don't get it. so here's the question: can one of you explain what it does in simple english?


Yes. In Python the percent sign (%) is called modulo, and essentially it takes two numbers (ex. 7 & 14) and divides it as many times as possible, then returns the remainder. So 7%14 = 7, because 7/14 = 0.5 and     0.5*14 = 7

An example problem is say you have 27 eggs, and cartons hold 12. You need to find how many eggs you will have left over after you put them in the cartons.

You would do 

eggs % 12

giving you the leftover eggs. 

oh that is what it does
thanks for helping me out  

The other use of % for string formatting is a bad habit to get into:

>>> "hello %s" % "world"

'hello world'

You should use something like this instead:

>>> "hello {}".format("world")

'hello world'