Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
For loop + add something
#1
Hello,

I am relevant new to the language Python. However, I can code in PHP and VBA and other languages so I am not a total beginner.


I am wondering how I can create a Loop that goes one by one

So Instead of just printing out the whole loop as this one does:
cars = ["Ford", "Volvo", "BMW"]
for x in cars:
  print(x) 
How do I do so it does like this:
cars = ["Ford", "Volvo", "BMW"]
for r = 1 to 3

variable(r) = "The car cars(r) has been sold"

Next r


Print("out all variables (should be 3 if the loop finnish)")
Results:
The car Ford has been sold
The car Volvo has been sold
The car BMW has been sold


Thanks in advance!
Reply


Messages In This Thread
For loop + add something - by Matheus - Jun-23-2022, 07:34 PM
RE: For loop + add something - by Axel_Erfurt - Jun-23-2022, 07:43 PM
RE: For loop + add something - by Matheus - Jun-23-2022, 09:12 PM
RE: For loop + add something - by Matheus - Jun-23-2022, 09:06 PM
RE: For loop + add something - by BashBedlam - Jun-23-2022, 09:16 PM
RE: For loop + add something - by snippsat - Jun-23-2022, 09:19 PM
RE: For loop + add something - by Matheus - Jun-23-2022, 09:37 PM
RE: For loop + add something - by DeaD_EyE - Jun-23-2022, 10:18 PM
RE: For loop + add something - by Pedroski55 - Jun-23-2022, 11:04 PM
RE: For loop + add something - by snippsat - Jun-24-2022, 01:03 AM
RE: For loop + add something - by DeaD_EyE - Jun-24-2022, 08:26 AM

Forum Jump:

User Panel Messages

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