Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 24th, 2012, 03:27 PM
TheLetterZero TheLetterZero is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 8 TheLetterZero User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 58 m 58 sec
Reputation Power: 0
Syntax Error

I feel a little silly for posting this question but I keep receiving an invalid syntax message when I try to run my program.

The line of code is:
if points >= attributes[trib]:

It is highlighting the colons at the end and telling me invalid syntax.

I italicized the line in my code below, if I counted correctly it's the eighth line up from the bottom.

What am I doing wrong here?

Thanks!

Code:
#character creator program allows user to distribute attributes
#in different areas to build up their character

#the attribute points for distribution and dictionary for attributes themselves
attpoints = 30
attributes = {"Strength" : "0",
              "Health" : "0",
              "Wisdom" : "0",
              "Dexterity" : "0"}

choice = None

print(
"""
RPG Character Generator

You will be given 30 attribute points to distribute as
you see fit so that your character will be strong enough
to vanquish evils across all the land!

You can add or remove points from attribute as you see fit.

"""
)

while attpoints and choice != 0:
    print("\nYou have", attpoints, "points available to distribute.")
    print("Your current attributes are as follows:")
    print("\nStrength:", attributes["Strength"])
    print("Health:", attributes["Health"])
    print("Wisdom:", attributes["Wisdom"])
    print("Dexterity", attributes["Dexterity"])
    print(
    """

    Press 0 to QUIT
    Press 1 to add points to an attribute
    Press 2 to remove points from an attribute
     """
    )

    choice = input("Enter your selection: ")
    if choice == "0":
        print("\nGood-bye")

    elif choice == "1":
        trib = input("What attribute would you like to add points to? ")
        if trib in attributes:
            points = int(input("How many points would you like to add? "))
            if points >= attpoints:
                print("Sorry, but you do not have that many points to")
                print("distribute, try again...")
            else:
                attpoints = attpoints - points
                attributes[trib] = attributes[trib] + points
                print("Your", trib, "is now set at", attributes[trib], "points!")
        else:
            print("That is not one of your attributes! Try again.")

    elif choice == "2":
        trib = input("What attribute would you like to remove points from? ")
        if trib in attributes:
            points = int(input("How many points would you like to remove? ")
            if points >= attributes[trib]:
                print("That's too many points to take away! Try again...")
            else:
                attpoints = points + attpoints
                attributes[trib] = attributes[trib] - points
                print("Your", trib, "is now set at", attributes[trib], "points!")
        else:
            print("That is not one of your attributes! Try again.")

Reply With Quote
  #2  
Old December 24th, 2012, 09:17 PM
metulburr metulburr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 10 metulburr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 43 m 57 sec
Reputation Power: 0
Code:
points = int(input("How many points would you like to remove? ")
            if points >= attributes[trib]:


you are missing a parenthesis the line above, so in essance it thinks your trying to convert everything here ^ to an int() in which causes an error upon :
Comments on this post
TheLetterZero agrees!

Reply With Quote
  #3  
Old December 24th, 2012, 09:18 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,357 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 9 h 10 m 17 sec
Reputation Power: 383
Line 63 is missing a right paren.

points = int(input("How many points would you like to remove? ")

python expressions span multiple lines until the parentheses are closed.
Comments on this post
TheLetterZero agrees!
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #4  
Old December 25th, 2012, 07:58 AM
TheLetterZero TheLetterZero is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 8 TheLetterZero User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 58 m 58 sec
Reputation Power: 0
Ahh

Thanks for responding to such a trivial post on Christmas Eve!

Reply With Quote
  #5  
Old December 25th, 2012, 08:14 AM
metulburr metulburr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 10 metulburr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 43 m 57 sec
Reputation Power: 0
what is more pathetic is that we both are on at christmas day

Reply With Quote
  #6  
Old December 25th, 2012, 08:56 AM
TheLetterZero TheLetterZero is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 8 TheLetterZero User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 58 m 58 sec
Reputation Power: 0
Hah, I don't have any family down where I'm at so it's just another day to me and everything is pretty much closed so what better way to spend it than expanding my (very limited) Python knowledge?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Syntax Error

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap