Hi all,
So I have attempted to start learning python and have got quite far into a script which reads a csv file.
Inside the csv file I have a field that has a number. For now lets say it is 8.
In my code it reads the field, stores it in a variable so I can re-use it later on.
Now has come the time to use this variable and I want to test it in a while loop.
Here is my code extract:-
This line reads the data into the myData variable and I can then pull out the field needed. This works perfectly and gives me the number 8.
Code:
myData = list(myReader)
csv_host_cnt = myData[5][2]
My issue is when I try to wrap this in a loop it goes crazy on me.
Code:
count = 0
while count < csv_host_cnt:
count = count + 1
print ("hello")
So it was my thinking that the loop would go round and round 8 times until the counter catches up and I would have 8x hello's on my screen?
What it does is just run an infinite loop and I have to ctrl-C the script.
I am at a loss here as I have tried all sorts of combinations of brackets and commas and ticks. But still no joy.
I apologise if this is a very basic problem. I am still learning and by the looks of it need all the help I can get!
Thanks in advance for your time.