+ 10
What would you do different?
I just published two python codes and I'd like to know what you would add or change. Thanks https://code.sololearn.com/cLuJywYg3bRi/?ref=app https://code.sololearn.com/ca56vFeFvSK4/?ref=app
3 Réponses
+ 5
Nice going!
For the first one, you could use a comprehension:
n = int(input())
print(sum(i**5 + 4*i**3 + 3*i**2 + 5 for i in range(1, n+1)))
...or even a one-liner:
print(sum(i**5 + 4*i**3 + 3*i**2 + 5 for i in range(1, int(input())+1)))
For the second one, I wouldn't use eval() as the name of a defined function because it's already the name of a built-in function.
Here's a variation on the code:
https://code.sololearn.com/cOgB9UfjI1vp
+ 6
David Ashton Awesome! 😁
Thank you for the feedback!
+ 1
Cristopher J Cardozo You're welcome - keep up the good work!