I need to find the length of elements within a string and return it to the user.
What is the best way of simplifying this code to make the amount of string lengths equate to user input? Also, how can I replace string1 with the user input, such as "The length of string 'Dog' is 3"?
num_of_items = int(input("How many items in your list? "))
def item_list(x):
items = []
for i in range(0, x):
item = input("Enter list %r: " % (i+1))
items.append(item)
length_items = ''.join(items)
return "Itemlist: %r" %(items), "Total length: %s"% len(length_items), \
"The length of string 1 is %r"%len(items[0]),\
"The length of string 2 is %r"%len(items[1]),\
"The length of string 3 is %r"%len(items[2]),\
"The length of string 4 is %r"%len(items[3])
print(item_list(num_of_items))