This is my code: Vigenere cipher :
from graphics import *
##def encode(message, keyword):
def main():
win= GraphWin("Vigenere cipher", 400,350)
messagebox = Text(Point(100, 60), "Enter message to encode")
keywordbox = Text(Point(63, 120), "Enter Keyword")
encodedbox = Text(Point(75, 250), "Encoded Message")
message = Entry(Point(290, 60), 20)
message.setText("")
keyword = Entry(Point(290, 120), 20)
keyword.setText("")
encode = Entry(Point(290, 250), 20)
encode.setText("")
messagebox.draw(win)
keywordbox.draw(win)
encodedbox.draw(win)
message.draw(win)
keyword.draw(win)
encode.draw(win)
button = Text(Point(280, 190),"Convert It!")
button.setOutline("black")
button.draw(win)
win.getMouse()
message = message.getText()
keyword = keyword.getText()
message = message.upper()
message = message.replace(" ","")
keyword = keyword.upper()
chars = []
for i in range(len(message)):
letter = (ord(message[i])-65)
keyword1= len(message) / len(keyword) + 1
keywordrepeated= int(keyword1) * keyword
adjustedletter = (ord(str(keywordrepeated[i]))-65)
encodedmessage= ((letter + adjustedletter)) % 26
encodedmessage= chr(encodedmessage + 65)
chars.append(encodedmessage)
encodedmessage = "".join(chars)
encode.setText(encodedmessage)
close = win.getMouse()
win.close()
main()
I am new to functions and need to know how to create a different function called
def encode(message, keyword): <------- and how to incorporate it into def main(): so the code wont be so bunched up in the middle, Thanks!!