I want to take an input from the user and and store it in a variable, lets say k. Then use this k as a counter for a for loop.
while i<k: doesn't work!
code:
k= input('number of points:')
p=[]
i=0
while i<k:
x=float(input('Enter value='))
p.append(x)
i=i+1
Output:
number of points:3
Traceback (most recent call last):
File "/home/ramupradip/tes.py", line 4, in <module>
while i<k:
TypeError: unorderable types: int() < str()
I also tried using range
for i in range(1,k)
which gave me an error: Traceback (most recent call last): File "/home/ramupradip/reflect.py", line 6, in for i in range(1,k): TypeError: 'str' object cannot be interpreted as an integer
int?Plz post errors that you getting