Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Optimisation
#2
(Dec-23-2019, 06:51 PM)H0M1C1D4L_P1G Wrote: as if I was to press enter it would of course execute the line of code so far
That is when you use interactive mode/shell (i.e. that is when you have >>>). Each line is evaluated immediately.
You should write your code and save it as file with py extension. In this case each statement will be on separate line

song = input("What is your favourite song?\n")
line1 = input("What\'s the first line?\n")
line2 = input("And the second?\n")
line3 = input("Finally, the third line?\n")
print(f"\n{song}\n{line1},\n{line2},\n{line3}")


Now there are other issues with your code (although it runs), but it's because there are better ways to do what you are doing here

look at https://python-forum.io/Thread-How-to-Ex...ython-code
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Optimisation - by H0M1C1D4L_P1G - Dec-23-2019, 06:51 PM
RE: Optimisation - by buran - Dec-23-2019, 09:18 PM
RE: Optimisation - by H0M1C1D4L_P1G - Dec-23-2019, 11:32 PM
RE: Optimisation - by ichabod801 - Dec-23-2019, 11:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Getting Started - Optimisation Problem lummers 1 1,752 Sep-19-2020, 05:05 AM
Last Post: perfringo
  Optimisation problem - star identification pberrett 1 2,281 Apr-01-2019, 12:17 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020