Oct-08-2019, 04:12 AM
(This post was last modified: Oct-08-2019, 04:45 AM by newbieAuggie2019.)
(Oct-08-2019, 02:48 AM)ericvrocha Wrote: I am trying to create a vector called "pressure", below is an example for the calculations that I have been trying to do.
pressure = [] i = 1 p0 = 50 pcp0 = 20 n = 10 while i < n: p1 = p0 - 0.17 * pcp0 for pressure in i: pressure.append(p1) i = i + 1 p0 = p1The error is for pressure in i:
TypeError: 'int' object is not iterable
Hi!
I find your code a bit strange.
First, your indentation seems to be wrong.
Second, we learnt at high school that a vector has 1 component if the vector is on a line, like v = (v1), 2 components if the vector is on a plane, like v = (v1, v2) and 3 components if the vector is in space, like v = (v1, v2, v3). I think you are trying to add 9 elements to your vector named 'pressure', from value i = 1 (line 3) to value i = 9 (lines 6, 7 and 11).
Third, your line 9:
for pressure in i:has no sense to me, because it is just a single value at a time.
Fourth, on your line 8:
p1 = p0 - 0.17 * pcp0p0 is a constant (p0 = 50), pcp0 is a constant (pcp0 = 20), so p1 is also a constant (p1 = (50) - (0.17 * 20) = 50 - 3.4 = 46.6) (it's independent of 'i' values, and it's not going to change).
Fifth, p0 = p1, is after what you intend to be a loop, so it's not going to change values in the loop either.
All the best,
newbieAuggie2019
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs