Linked Questions

Popular Questions

Why does a syntax error happen in my code?

Asked by At

The string method I want to use:

s.count(sub[, start[, end]])

A syntax error occurs at the first comma.

An error occurs at the first comma, so I checked several times if all the '[' signs or the ')' signs are used as a set(as in 'closed').

s = input("Enter a sentence that contains at least 4 words: ")

print("c) ", ljust(s, 50, fillchar='/'))
print("d)", s.count('oh'[, 1[, 5]]))
print("e)", s.index('oh'[, 1[, 5]]))

The first comma inside the count method shows an invalid syntax error. Just for your reference, I attached the line before and after the erroneous code, as well. Is there a parentheses that is not closed, or are there any errors besides the one I have thought about?

Related Questions