1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

len() function

Discussion in 'Civ4 - Creation & Customization' started by Thalassicus, Jan 9, 2006.

  1. Thalassicus

    Thalassicus Bytes and Nibblers

    Joined:
    Nov 9, 2005
    Messages:
    11,057
    Location:
    Texas
    How do you use the len() function? I tracked down a bug to a line where I reference the length of a list, so I tested this and it gave an error:

    Code:
    blockedCities = ["Test"]
    testInteger = len(blockedCities)
    if (testInteger == 1):
        ## Do nothing
    
    What could the problem be? I think this is the correct syntax. I also tried blockedCities.len().
     
  2. Requies

    Requies Prince

    Joined:
    Nov 15, 2005
    Messages:
    381
    You didn't get a syntax problem with this? You can't just "do nothing" in a clause of an "if" statement. You have to at least "pass".

    also len should return 1, but it might be strange because you only have a string in there, so I don't know what the behavior would be (I think it should still return 1, but, I'm not certain about it.)

    Req
     
  3. Thalassicus

    Thalassicus Bytes and Nibblers

    Joined:
    Nov 9, 2005
    Messages:
    11,057
    Location:
    Texas
    Ohh, I see, didn't know that. I was used to using if (check) {} statements. Thanks :)
     

Share This Page