Even the last... Any imporvments / comments ???
def main():
def get_list(): list = [] user_input = "" while len(user_input) >= 20 or len(user_input) <= 0: user_input = input("Enter: ") user_input = user_input.split(" ") for i in range(0, len(user_input)): if not len(user_input[i]) == 0: try: user_input[i] = int(user_input[i]) list.append(user_input[i]) except ValueError: print("Must be an integer...") return list def get_result(list): result = 0 list = list[0 : len(list): 2] for i in range(0, len(list)): if i == len(list) - 1: continue result += list[i] if len(list) > 1: for y in range(0, len(list)): if y + 1 == len(list): result = result * list[y] elif len(list) == 1: result = result ^ 2 return result def start(): a = get_list() print (get_result(a)) start()
while True: main()