Answer:
lst = []
n = int(input("Input an array size for you words array: "))
print("Now please enter " + str(n) + " words")
max = 0
min = 1000
index_min = 0
index_max = 0
for i in range(n):
s = input("Input a word: ")
lst.append(s)
if len(s) >= max:
max = len(s)
index_max = i
if len(s) <= min:
min = len(s)
index_min = i
print("The longest word is :" + lst[index_max])
print("The shortest word is :" + lst[index_min])
Step-by-step explanation:
Create an empty list, lst
Get the size from the user
Create a for loop that iterates "size" times
Inside the loop, get the strings from the user and put them in the lst. Find the longest and shortest strings and their indices using if structure.
When the loop is done, print the longest and shortest