View Single Post
Old 22 August 2015, 16:54   #284
Total Chaos forever!

Samurai_Crow's Avatar
Join Date: Aug 2007
Location: Ft. Collins, CO USA
Age: 43
Posts: 989
Send a message via Yahoo to Samurai_Crow
Originally Posted by Lonewolf10 View Post
And, for what it's worth, I much prefer the syntax in BASIC just the way it is.
I personally don't understand lines such as:
For I in A ...
I in A? If I=1 what does A equal? 1?
If it's anything like Javascript, it means that if A is a collection such as a variable-length array or linked-list, each time through the loop it will equal the value that is in the next element of A. Python's For loop is exclusively this type to the point that it doesn't support the old fashioned way at all (or at least not directly)!

For I in ["Alphabet", "soup", "contains", "vegetables"]
  print I
Next I
Would output:

For some mythical BASIC with this type of For loop (more commonly known as ForEach in general or ForAll in AmigaE).

In Python, for example, if you want to count from 1 to 30, you do something like this:
for x in range(30):
  print x
(Note that anything ending with a colon indicates the start of a block and the indent level marks the extent of the block.)
Samurai_Crow is offline  
Page generated in 0.03903 seconds with 10 queries