if/else SyntaxError: invalid syntax Python

Viewed 31

What should I do to correct the code? I already looked at it several times but without progress.

num=int(input())

if num%2 == 0:
    print(("-" * ((num/2)-1) + "*" + ("-" * ((num/2)-1))
else:
    print("odd")

And this is the error:

File "<string>", line 5
else:
^
SyntaxError: invalid syntax
> 
1 Answers

You just forget to close some paranthese.

Try this

num=int(input())

if num%2 == 0:
    print("-" * ((num/2)-1) + "*" + "-" * ((num/2)-1))
else:
    print("odd")

Related