SubhanUllah Posted October 24, 2022 Report Posted October 24, 2022 my_list = ["A","B","C","Dummy"] junk_list = [] while True: new_value = input("Enter a value 'quit' to end:") if new_value == "quit": break if new_value.isalpha(): my_list.append(new_value) else: junk_list.append(new_value) print(f"Alpha list is: {my_list}") print(f"Junk List is: {junk_list}") Output Enter a value 'quit' to end:dddd Enter a value 'quit' to end:tttt Enter a value 'quit' to end:555 Enter a value 'quit' to end:@#44 Enter a value 'quit' to end:quit Alpha list is: ['A', 'B', 'C', 'Dummy', 'dddd', 'tttt'] Junk List is: ['555', '@#44'] Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.