0

Sums of two squares bug!

My first code in python outputs a list of sums of two squares. I can’t figure out why it won’t output the number 1! Can anyone help? https://code.sololearn.com/cFDI7wpTm7yP/?ref=app

1st Dec 2020, 5:18 AM
Ethan
Ethan - avatar
1 Odpowiedź
+ 2
For 0, your second loop is ignoring it. "for root1 in range(i)" When i=0, the loop is skipped. range(start, stop, step) API: start defaults to 0 (inclusive) stop is compulsory (exclusive) step defaults to 1 You might want to change it to "for root1 in range(i+1)" Similarly for the third loop.
1st Dec 2020, 8:36 AM
Lam Wei Li
Lam Wei Li - avatar