1

I'm working on the exercises in Learning Python the Hard Way and I am wondering what the % function does. I am getting the wrong answer when i count my eggs and hoping understanding this will help me understand what I'm doing wrong.

Sqyer
  • 83
  • 4
  • Could you please provide the relevant part of the exercise? not everyone is familiar with LPTHW. – keppla Sep 13 '11 at 07:20

2 Answers2

12
  1. I can't really tell why your code is broken because you haven't shown anybody what your code is. Please post samples and links next time.
  2. Python % is used in two places, one is mathematical (the modulo operator), and the other has to do with formatting text. I'm going to assume "counting eggs" means the math way.
  3. The modulo operator in X % Y means "Divide X by Y and give me the remainder." So:

    10 % 2 == 0
    10 % 3 == 1
    10 % 11 == 10

TheLQ
  • 14,830
  • 14
  • 69
  • 107
Darien
  • 3,482
  • 19
  • 35
2

That is the the modulo operator

Ed S.
  • 122,712
  • 22
  • 185
  • 265