I have created a program on pycharm which allows the user to input a number so a list of items can be created. The program is as follows:
item = int(input("How many items do you want in your list? "))
stringList = []
for i in range(1, item +1):
stringList.append(input("Enter String {0}: ".format(i)))
print(stringList)
An example of what could be output shows as follows:
How many items do you want in your list? 3
Enter String 1: apple
Enter String 2: banana
Enter String 3: grape
['apple', 'banana', 'grape']
What I'm wanting to do now is to add the length of each string that has been typed by the user. I am fairly new to python and was wondering how one would add the length so the output would be something like this:
Enter String 1: apple
Enter String 2: banana
Enter String 3: grape
['apple', 'banana', 'grape']
The length of the string 'apple' is 5
The length of the string 'banana' is 6
The length of the string 'grape' is 5
The total length of all strings is 21