In: Computer Science
Please write in beginner level PYTHON code!
Your job is to write a Python program that asks the user to make one of two choices: destruct or construct.
- If the user chooses to destruct, prompt them for an alternade, and then output the 2 words from that alternade.
- If the user chooses construct, prompt them for 2 words, and then output the alternade that would have produced those words.
- You must enforce that the users enter real words or at least not blatant non-words. So if their input contains numbers, whitespace, punctuation, etc., you should prompt them for input until correct input is provided.
- If you manage to get all that done, then implement the following: the words output by your program must be in alternating case, starting with uppercase.
count = 0
choice = input("Would you like to destruct 'd' or construct 'c' an alternade: ")
while count == 0:
if choice == 'd': #if user chooses destruct
d_word = input("Enter in alternade: ")
test = d_word.isalpha() #checks if string is alphabets
if test == False:
count = 0
else:
first_word = d_word[0::2]
second_word = d_word[1::2]
print("The words are",first_word,"and",second_word)
break
if choice == 'c': #if user selects construct
first_c_word = input("Enter first word: ")
second_c_word = input("Enter second word: ")
first_test = first_c_word.isalpha() #checks if string is alphabets
if first_test == False:
count = 0
second_test = second_c_word.isalpha() #checks if string is alphabets
if second_test == False:
count = 0
else:
count = 1
if count == 1:
index_count = 0 #count for second word
word = ''
for char in first_c_word:
char
word += char + second_c_word.upper()[index_count]
index_count += 1
if len(second_c_word) == index_count:
print("The word is",word) #print for user
break