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")

or

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

and data

Hint ...

# 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")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.