Python Forum
question about input, while loop, then print
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
question about input, while loop, then print
#2
Have you used lists yet? here is an example of appending items to a list and then loop through the items of the list.
names = []

for number in range(1, 4):
    names.append(f"name: {number}")


for name in names:
    print(name)
Output:
name: 1 name: 2 name: 3
See if you can incorporate a list into your code.
Reply


Messages In This Thread
RE: question about input, while loop, then print - by Yoriz - Sep-28-2021, 06:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  WHILE LOOP NOT RETURNING USER INPUT AFTER ZerroDivisionError! HELP! ayodele_martins1 7 1,359 Oct-01-2023, 07:36 PM
Last Post: ayodele_martins1
  Code won't break While loop or go back to the input? MrKnd94 2 1,157 Oct-26-2022, 10:10 AM
Last Post: Larz60+
  Question: print issue python202209 3 1,090 Sep-18-2022, 11:51 AM
Last Post: jefsummers
  WHILE Loop - constant variables NOT working with user input boundaries C0D3R 4 1,654 Apr-05-2022, 06:18 AM
Last Post: C0D3R
  input function question barryjo 12 3,096 Jan-18-2022, 12:11 AM
Last Post: barryjo
Big Grin General programming question (input string)[ jamie_01 2 1,747 Jan-08-2022, 12:59 AM
Last Post: BashBedlam
  A question about 'Event loop is closed' fc5igm 2 2,455 Oct-05-2021, 02:00 AM
Last Post: fc5igm
  why print('\n') produced 2 new lines instead of 1 - Located inside a FOR loop JulyFire 2 2,701 Jan-10-2021, 01:50 AM
Last Post: JulyFire
  I want to check if the input is str or is int & if it's str repeat the loop HLD202 4 2,955 Nov-23-2020, 11:01 PM
Last Post: perfringo
  Loop back through loop based on user input, keeping previous changes loop made? hbkpancakes 2 3,081 Nov-21-2020, 02:35 AM
Last Post: hbkpancakes

Forum Jump:

User Panel Messages

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