dimanche 29 mars 2015

How to check for three or more whitespaces in string - Python

I need a method to check if there are three o whitespaces a string. Currently I only know how to check if there is a whitespace, with this: if " " in someString:. The reason why I want to find how many whitespaces there are, is because I need to narrow the search down of decrypted messages.


You see, the encrypted message is a long string of random letters and numbers. I use itertools.product("abcdefghijklmnopqrstuvwxyzæøå", repeat=6) to generate a set of keys, assuming the length of the key is six. In order to find the correct original message, which is a setence in english I need to narrow down the search. I figured out that checking for three or more whitespaces in a string is a great way to do so, since a sentence usually consist of multiple whitespaces.


I really want some tips, rather than the solution, since this is a task I want to figure out by myself! :D


Aucun commentaire:

Enregistrer un commentaire