dimanche 10 mai 2020

How can I fix SyntaxError: invalid syntax when trying to pad zeros to a numeric string?

for i in range(1,50): 
    path = if i < 10:
               url + '0' + str(i)
           else:
               url + str(i)

    df = pd.read_html(path)

in this situation, I got

SyntaxError: invalid syntax for 'if'.

how can I fix this code?

Aucun commentaire:

Enregistrer un commentaire