+ 1

What is wrong with this code? TypeError: 'float' object is not iterable

Hey, guys! I'm trying to create a program that makes a logistic map. I use two files for that: First: def log_map(x,r,n): """ Creates a logistic map with initial value x, a parameter r and a number of iterations n. """ for i in range(n): if i==0: y = list(x) y.append(r*x*(1.-x)) else: y.append(r*y[i-1]*(1.-y[i-1])) return y Second: from log_map import log_map x = input("Enter x: ") r = input("Enter r: ") n = input("Enter n: ") y = log_map(x,r,n) print(y) It opens normally and asks for the correct inputs, but then it gives the message "TypeError: 'float' object is not iterable". I don't understand what the problem really is... Could you help me?

2nd Aug 2018, 7:31 PM
igokra
igokra - avatar
2 Respuestas
+ 3
try putting the inputs like this x = int(input("enter x: "))
2nd Aug 2018, 7:38 PM
LONGTIE👔
LONGTIE👔 - avatar
- 1
Longtie, but they are supposed to be floats.
7th Aug 2018, 4:18 PM
igokra
igokra - avatar