I'm writing a program that is going to be used for encryption. It can only encrypt 64 letters at a time. How can I make a check for that using len()?
Your question is very opaque. I suspect it is already encrypted. Nevertheless, try this:
try: input = raw_input except NameError: pass data = input("Please enter a 64 letters string: ") if len(data) == 64: print("SUCCESS") else: print("FAILURE")
data = str(input("Please enter a 64 letters string: ")) if (len(data) <= 64) and (len(data) > 0): print("SUCCESS") else: print("FAILURE")
and len(data) > 0
Only way len not to fulfill this condition is data to be empty value, which is False value in Python, so the condition could be
# this test string will have 65 characters s = 'q' * 65 length = len(s) if length <= 64: encrypted = encrypt(s) else: print("string exceeds 64 characters")