Python Forum

Full Version: Syntax Error in Program
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have installed python 3.6.0 on my laptop and using IDLE to write below program
but i am getting syntax error.

Can you suggest please >

Write a Python program to count the number 4 in a given list.

Program-

def list_count_4(nums):
  count = 0  
  for num in nums:
    if num == 4:
      count = count + 1

  return count

print(list_count_4([1, 4, 6, 7, 4]))
print(list_count_4([1, 4, 6, 4, 7, 4]))
Quote:but i am getting syntax error.
Post the exact error you are getting
Your program is working on my computer. Of course, on the first line, we should read def instead of ef.