diff --git a/diceware/random_sources.py b/diceware/random_sources.py
index 95ac5b6bd2978a49bddf7acdddb97b0f30030c78..4b95ab8eb6cafd09f7012156ea88323b146ca06e 100644
--- a/diceware/random_sources.py
+++ b/diceware/random_sources.py
@@ -132,7 +132,7 @@ class RealDiceRandomSource(object):
         acceptable range and issue an hint about the procedure.
         """
         if num_rolls == 0:
-           raise(ValueError)
+            raise(ValueError)
         if (self.dice_sides ** num_rolls) < len(sequence):
             print(
                 "Warning: entropy is reduced! Using only first %s of %s "
@@ -151,18 +151,20 @@ class RealDiceRandomSource(object):
         num_rolls = int(math.log(len(sequence), self.dice_sides))
         use_modulo = False
         if num_rolls < 1:
-           # If this happens, there are less values in the sequence to choose from than there are dice sides.
-           # First check whehter the length is 1. Then we don't have to do anything else
-           if len(sequence) == 1:
-           # Check whether len(sequence) is a factor of dice.sides
-              return sequence[0]
-           if self.dice_sides % len(sequence) == 0:
-              use_modulo = True
-              num_rolls = 1
-           else:
-              # otherwise We will perform one extra roll and apply modulo
-              use_modulo=True
-              num_rolls = 2
+            # If this happens, there are less values in the sequence to
+            # choose from than there are dice sides.
+            # First check whehter the length is 1. Then we don't have
+            # to do anything else
+            if len(sequence) == 1:
+                # Check whether len(sequence) is a factor of dice.sides
+                return sequence[0]
+            if self.dice_sides % len(sequence) == 0:
+                use_modulo = True
+                num_rolls = 1
+            else:
+                # otherwise We will perform one extra roll and apply modulo
+                use_modulo = True
+                num_rolls = 2
         self.pre_check(num_rolls, sequence)
         result = 0
         for i in range(num_rolls, 0, -1):
diff --git a/tests/test_random_sources.py b/tests/test_random_sources.py
index c29375a29801b707f64c54896b3c0f03acbdf2be..c101bceb0df11ebef1bc17dd488f03e3d17e89d7 100644
--- a/tests/test_random_sources.py
+++ b/tests/test_random_sources.py
@@ -258,7 +258,8 @@ class TestRealDiceRandomSource(object):
         assert "Please roll 5 dice (or a single dice 5 times)." in out
 
     def test_sequence_less_than_dice_sides(self, capsys, monkeypatch):
-        # Test to see whether we can use a n-sided die to choose from a sequence with less than n items
+        # Test to see whether we can use a n-sided die to choose from
+        # a sequence with less than n items
         src = RealDiceRandomSource(None)
         src.dice_sides = 6
         # A length of 1 requires no rolls
@@ -268,16 +269,16 @@ class TestRealDiceRandomSource(object):
         assert "roll" not in out
         assert picked == 1
         # A length of 2,3 only requires 1 roll
-        for choice_length in (2,3):
+        for choice_length in (2, 3):
             self.fake_input_values(["1"], monkeypatch)
-            picked = src.choice(range(1,choice_length + 1))
+            picked = src.choice(range(1, choice_length + 1))
             out, err = capsys.readouterr()
             assert "roll 1 dice" in out
             assert picked == 1
         # A length of 4,5 requires 2 rolls
-        for choice_length in (4,5):
-            self.fake_input_values(["1","1"], monkeypatch)
-            picked = src.choice(range(1,choice_length + 1))
+        for choice_length in (4, 5):
+            self.fake_input_values(["1", "1"], monkeypatch)
+            picked = src.choice(range(1, choice_length + 1))
             out, err = capsys.readouterr()
             assert "roll 2 dice" in out
             assert picked == 1