Syntax error in Python 3.7

Asked

Viewed 128 times

1

I am practicing a course exercise and came across the following error below. I am using Python 3.7. What’s the problem with this typing?

convite = 'Flavio Henrique Almeida'
parte1 = convite[0:4]
parte2 = convite[11:15]
print "%s %s" % (parte1, parte2)

Error:

File "<stdin>", line 1
  print "%s %s" % (parte1, parte2)
                ^
SyntaxError: invalid syntax

1 answer

2

The mistake is in the print "%s %s" % (parte1, parte2). In Python 3 you need to put the arguments of print in brackets (, ), like any other function call.

In case it would look like this:

print("%s %s" % (parte1, parte2))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.