Python additional questions...

Asked 2 years ago, Updated 2 years ago, 17 views

x = (int(input("How many items do you want in your list? ")))
items = []
for i in range(1, x + 1):
    items.append(input("Enter string " + str(i) + ":"))

print(items)

If you put 2 and apple and banana, it says ["apple", "banana"]

Also, you want to find the length of the string here.

The length of the string ‘apple’ is: 5 The length of the string ‘banana’ is: 6 Total length of the strings is: 11

What should I do to express it as?

python

2022-09-21 21:11

1 Answers

Use len () you can.


2022-09-21 21:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.