Welcome, Guest

Author Topic: i need this code  (Read 1594 times)

atomic7732

  • Global Moderator
  • *****
  • Posts: 3849
  • caught in the river turning blue
    • Paladin of Storms
i need this code
« on: September 20, 2012, 08:43:12 AM »
Visual Basic
Code: [Select]
       If control(0) = "A" Then
            procount(0) = procount(0) + 1
        ElseIf control(1) = "A" Then
            procount(1) = procount(1) + 1
        ElseIf control(2) = "A" Then
            procount(2) = procount(2) + 1
        ElseIf control(3) = "A" Then
            procount(3) = procount(3) + 1
        End If
not to mention that this is only checking 4 spots in an array, think of all the copying and pasting if you have 16 indices... or 64... or more!

Python
Code: [Select]
pcount = 0

control = [
    "A", "B", "C", "D", "A", "A", "B", "A"
]

for x in control:
    if x == "A":
        pcount = pcount + 1
        
print pcount    

Any amount in the array and the same 3 lines of the for loop works. BOOM

Or maybe I don't know how to do a for loop in VB

Actually that's probably it.


Anyway I need this code for reasons. I'll try to make a map game using python with TkInter and stuff yes.


 ^ How far I was in VB
« Last Edit: September 20, 2012, 12:25:06 PM by atomic7732 »

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: i need this code
« Reply #1 on: September 20, 2012, 12:13:17 PM »
have you figured out how to erase or move lines/objects in tkinter?

atomic7732

  • Global Moderator
  • *****
  • Posts: 3849
  • caught in the river turning blue
    • Paladin of Storms
Re: i need this code
« Reply #2 on: September 20, 2012, 12:20:15 PM »
yes I can erase a specific id, but not any/all, sadly