import math
while True:
message=str(input("please drop your message\n>"))
key=int(input(f"\nkey: make sure the key should be greater than 2 and less than{int(len(message)/2)}\n>"))
decision=input("\ndo you want to (e)ncrypt or (d)ecrypt...\n>")
column=int(math.ceil(len(message)/key))
array,row,a,b=[],[],0,0
if decision=="e":
for symbol in message:
if a==key:
array.append(row)
row=[]
a=0
row.append(symbol)
a+=1
if len(row)<key-1:
for i in range(key-len(row)):
row.append("#")
array.append(row)
row=[]
for x in range(key):
for y in range(column):
row.append(array[y][x])
print("\nhere is your cipher text....\n",("").join(row))
elif decision=="d":
for symbol in message:
if a==column:
array.append(row)
row=[]
a=0
row.append(symbol)
a+=1
if len(row)<column-1:
for i in range(column-len(row)):
row.append("#")
array.append(row)
row=[]
for x in range(column):
for y in range(key):
row.append(array[y][x])
print("\nhere is your plain text...\n",("").join(row))
else:
print("your decision is wrong\nplease try again....")
break
play_again=(input("\ndo you want to continue yes or no\n>").upper())
if play_again=="NO":
print("\nThanks for creating passwords...")
break
elif play_again=="YES":
pass
else:
print("please try again....")
pass