User Profile
Collapse
-
I feel stupid for not having caught this obvious error...thank you all. -
I changed my code, but for some reason it still doesn't work. There isn't an error displayed, just nothing happens.
Code:number = int(input(" Enter a number ")) x = 1 coollist = [] while x <= pow(int(number),0.5): if (number % x) == 0: coollist.append(x) else: x += 1 coollist.append(number) print coollist
Leave a comment:
-
i still get an error(when adding the extra parenthese at the end of sqrt in my while loop) it says that "sqrt" is not defined. I used bvdet's code exactly.(His first revision)Leave a comment:
-
So, what would you recommend in order to fix the syntax error?Leave a comment:
-
Syntax error in a while loop
In my program to brute force all the factors (not including 1) of a number, there is a syntax error in my while loop. The code looks like this.
Code:number = raw_input(" Enter a number ") x = 2 coollist = [] while x <= sqrt(int(number): if number % loop == 0: coollist.append(x) else: x += 1 print coollist
... -
I am sorry for this nonrelated post, but can someone kick fgjtydger out of the forum because i dont know how.Leave a comment:
-
Thanks bvdet and dwblas, in my python path there was another random.py file which was being read before the random module.
Thank you all.Leave a comment:
-
AttributeError: 'module' object has no attribute 'randint'
i am a beginner, i tried to have python generate a random integer from 0 to 10
my code looks like this:
import random
number = random.randint( 0,10)
print number
i am using python 2.7
it gives AttributeError: 'module' object has no attribute 'randint'
please help, thank you very much.
No activity results to display
Show More
Leave a comment: