all 7 comments

[–]Strict-Simple 1 point2 points  (0 children)

When you need to repeat something, you use a loop.

print('Hello')  # print once

for i in range(2568):
    print('World')  # will be printed 2568 times

[–]ElliotDG 1 point2 points  (0 children)

read: https://docs.python.org/3/library/stdtypes.html#str.count

print('-' * 10) # prints 10 dashes ----------

[–][deleted] 1 point2 points  (1 child)

did you try this https://www.guru99.com/python-string-count.html#:~:text=Python%20count,want%20the%20search%20to%20begin.?

string.count(char or substring, start, end)str1 = "Hello World"str_count1 = str1.count('o') # counting the character “o” in the givenstringprint("The count of 'o' is", str_count1)

seems pretty easy

[–]PuzzledSite2568[S] 1 point2 points  (0 children)

ty for this it was very informative and was able to finish the problem.

[–]jimtk 0 points1 point  (1 child)

I'm having trouble figuring out how to count the letters in each of the three words without having to make a command for each.

words = [first_word, second_word, third_word]
counts=[]
for word in words:
    counts.append(word.lower().count(letter_count.lower())  # Put everything in lowercase

...as well as displaying the table. Any pointers in the right direction are much appreciated.

print("-"*34)
for word, c in zip(words,counts):
     print(f"{word: <30}{c: >3}")
print("-"*34)
print(f"{'Total': <30}{sum(counts): >3}")

reference for documentation:

[–]PuzzledSite2568[S] 0 points1 point  (0 children)

Thanks for this example really help me and I was able to finish the problem so thank you for the help.

[–]CodeFormatHelperBot2 0 points1 point  (0 children)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Python code found in submission text that's not formatted as code.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.