0
Diference from python2 to python3 in this code to solve it
How do I have to fix the line 11, I write this code in python 2.7, and ends well, but in python3 always give me an error, it seems that is in line 11, because the result of division n/2 always is a float, and n have to be an int number for range, thanks https://code.sololearn.com/cQI41S4ruQ66/?ref=app
5 Answers
+ 8
The range function only accepts integer values as its parameters.
Use the floor division operator instead : n//2+1
This will remove the above error.
+ 6
TiTo90 Yeah, SoloLearn and many other Online Courses don't provide in-depth knowledge. You need to refer multiple resources to learn.
Here's a thread that contains a few Python 3 resources:
https://www.sololearn.com/Discuss/821134/?ref=app
Hope it's helpful đ
+ 5
No, need for python 2 now...
It's no more used.
https://code.sololearn.com/cIb0jKxWo4Oq/?ref=app
+ 1
By the way, for finding the divisors of a number, as when we check for primality, it's enough to search up to the square root of n, not up to the half of n
0
The thing is that I'm studying by a book that teach 2.7, and this is the best book I have, it have exercises and everything well explain, I've searching in other courses in internet, and even here in solo learn, and they teach very superficial đđđ, and since python 2 to 3 at least now by this book, there are so much, I continue studying đ€·đ€·đ€·