Use the in operator:
encrypt = 'd' if raw_input("Encrypt or decrypt a file (E/d):") in ('d', 'D') else 'e'
Alternatively, you can just convert the input to lowercase and compare it to 'd':
encrypt = 'd' if raw_input("Encrypt or decrypt a file (E/d):").lower() == 'd' else 'e'
Finally, if you want to ensure that they enter e or d, you can wrap it up in a while loop:
while True:
encrypt = raw_input("Encrypt or decrypt a file (E/d):")
# Convert to lowercase
encrypt = encrypt.lower()
# If it's e or d then break out of the loop
if encrypt in ('e', 'd'):
break
# Otherwise, it'll loop back and ask them to input again
Edit: To answer your second question, you can use a lambda for it I guess?
file_text = (lambda default, inp: default if inp.lower() == default else inp)("a.txt", raw_input("File name(a.txt):"))
Although, this is clearly a bit obtuse and too "clever" by half.
encrypt = raw_input("Encrypt or Decrypt a file(E/d):" if encrypt != 'd' or encrypt != 'D': encrypt != 'e'I also like to look for unusual and different ways to do programing