Nov-05-2016, 06:51 PM
(This post was last modified: Nov-05-2016, 06:52 PM by SrirachaSauceLover.)
(Nov-05-2016, 06:14 PM)Barrowman Wrote: I think your code should be more like this:Could you tell me how you put the second "main()" so it's in line with "def main():" ? I think that's the solution. When I press <Enter> after I type "print(x)", it lowers the cursor directly beneath it. The <Tab> doesn't help me either.
#!/usr/bin/env python def main(): inp = raw_input("Enter a value between 0 and 1: ") x = float(inp) for i in range(10): x = 3.9 * x * (1 - x ) print x main()
By the way, the code isn't mine; it's from Zelle's book.
(Nov-05-2016, 06:18 PM)nilamo Wrote: First, start by removing that terrible function "eval". It's dripping with pure "evil". Then get rid of the call to main() within main(), there's no reason for nonsense like that.
Does it at least run? What's the filename, and what's the script you're using to import it?
Yes, it runs. The filename is "chaos.py". I import it with "import", thought Zelle mentions other methods, and they don't work either.