# generate a function: def generate_cubed_sequence(): # Step 1: Obtain and Validate Inputs # I should put the loop at the beginning of the code while True: # define the variable inside the loop itself maxValue = input("Enter an integer that represents the max value: ") try: # if the conversion succseed, check if the value >=1 maxValue = int(maxValue) if maxValue>=1: print(f"Generating sequence with max value {maxValue}") # if everything follows all conditions and I want to leave the loop break # if conversion succeed but value<1: else: print("Invalid Input") except ValueError: print("Invalid Input") pass # Step2: Generate the sequence sequence = [] x =1 cubed = x**3 while cubed <= maxValue: sequence.append(cubed) x+=1 cubed=x**3 return sequence print(generate_cubed_sequence())