Unable to combine print statements in for loop - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Unable to combine print statements in for loop (/thread-27596.html) |
Unable to combine print statements in for loop - adeana - Jun-12-2020 I am learning Python on my own. I am using Python Crash Course by Eric Matthes. Chapter 4: Looping through a Slice - #my list players = ['charles', 'martina', 'michael', 'florence', 'eli'] #my instruction is to print out the first three players names of the team using a for loop. Book lays out the format like this; print("Here are the first three players on my team:") for player in players[:3]: print(player.title())#my output should be #I am using Python 3.8.1 Shell and I am unable to figure out how to combine both print statements to read as the output. When I type the first print statement and hit enter, it prints before I can enter the for loop information. How do I get the output that the book says that I should expect? RE: Unable to combine print statements in for loop - buran - Jun-12-2020 it looks like you are entering your code in python interactive shell. that is when you have >>> at the start of the line. In this mode every line is evaluated and executed immediately.You need to write your code in a file and save it as file with py extension and then execute it. Look at https://python-forum.io/Thread-How-to-Execute-python-code for more info RE: Unable to combine print statements in for loop - adeana - Jun-12-2020 Thank you for your help. |