lundi 5 août 2019

How to type if elsif on a line inside for for in python

I want to get the minimum lines for the code

However I need a condition where i ** 2> num is sending a message with elif, else works but the code gets an error getting the square root

(GoTr)

num = int(input('num: ')); [print(f'Raiz({num}) = {i}') for i in range(1, num) if i ** 2 == num]

Aucun commentaire:

Enregistrer un commentaire