I read the PEP8 document, but it was my first time.
Honestly, I don't know how to fix it, so I would appreciate it if you could point it out.
Error Message
too many blank lines
Error Message Location
def popular_article(query1):
Code
def popular_article(query1):
db=psycopg2.connect("dbname=news")
c=db.cursor()
c. execute(query1)
results=c.fetchall()
for in results:
print("{0}--{1}views".format(e[0], e[1]))
db.close()
Lines 55 to 57 exceed 79 characters, so
I made it into three lines, but I got the following error.
Error Message
line break before binary operator
missing space after', '
Error Message Location
print(date.strftime('%B%d,%Y')
+ ' ' + '--' + ' '
+ str(round(per_err,1)))+'%'+'+'errors')
Code
default_percent(query3):
db=psycopg2.connect("dbname=news")
c=db.cursor()
c. execute(query3)
results=c.fetchall()
for in results:
date=(e[0])
per_err=(e[1])
print(date.strftime('%B%d,%Y')
+ ' ' + '--' + ' '
+ str(round(per_err,1)))+'%'+'+'errors')
db.close()
Error Message
no newline at end of file
Error Message Location
error_percent(query3)
Code
if__name__=='__main__':
print("The 3most popular articles of all time are:")
popular_article(query1)
print("\n")
print("The most popular article authorities of all time are")
popular_author(query2)
print("\n")
print("Days did more than 1% of requests lead to errors")
error_percent(query3)
Correct the error as it is.
+
. You are getting an error because you are breaking a new line before +
, so try to break a new line after +
.round(per_err,1)
.+
. You are getting an error because you are breaking a new line before +
, so try to break a new line after +
.round(per_err,1)
.
© 2024 OneMinuteCode. All rights reserved.