Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why is this not working
#1
def cos(x):
    while x<=0:
        print("Podaj prawidłową liczbę\n")
        x = int(input("Podaj liczbę większą od zera różną od 0\n")
    if x>0:
        return (x)
x = int(input("Podaj liczbę większą od zera różną od 0\n"))
cos(x)
Error:
File "C:\Users\mateu\PycharmProjects\pythonProject1\main.py", line 5 return (x) ^ SyntaxError: invalid syntax
Reply
#2
On line 4 there are two open brackets but only one close bracket, add the missing close bracket to the end of the line.

Note: Also it looks like the code has been altered since the error trace that has been shown because there is now an if statement that would now be the line the error would show up on.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020