<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Crazy weird symtax errors, please help' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Crazy weird symtax errors, please help' posted on the 'Python' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2012 Programmers Heaven</copyright>
    <pubDate>Wed, 23 May 2012 23:39:06 -0700</pubDate>
    <lastBuildDate>Wed, 23 May 2012 23:39:06 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Crazy weird symtax errors, please help</title>
      <link>http://www.programmersheaven.com/mb/python/408988/408988/crazy-weird-symtax-errors-please-help/</link>
      <description>Hey, I just got the newest version of python, Python 3.1.&lt;br /&gt;
I am getting the craziest, most out-there syntax errors ever, and I have no idea what to do.&lt;br /&gt;
Okay, here's a section of code that i just wrote to prove how crazy these errors really are:&lt;br /&gt;
&lt;br /&gt;
import random&lt;br /&gt;
&lt;br /&gt;
your_name = input("What is your name?")&lt;br /&gt;
nicknames = ("Fruitcup", "Captain", "Bunny", "Mama", "Dummkopf")&lt;br /&gt;
nickname = random.choice(nicknames)&lt;br /&gt;
or_not = input("Do you mind if I call you", nickname, "?")&lt;br /&gt;
if or_not == ("yes"):&lt;br /&gt;
    print ("Fine &lt;span style="color: Red;"&gt;th&lt;/span&gt;en,", your_name, ".")&lt;br /&gt;
    answer = input("""&lt;br /&gt;
    Answer this &lt;span style="color: Red;"&gt;th&lt;/span&gt;en,&lt;span style="color: Red;"&gt;"&lt;/span&gt;"", your_name, """:&lt;br /&gt;
    \tIf two ducks have 5 ducklings, and three of those ducklings have\n&lt;br /&gt;
    \t10 ducklings each, how many ducks do you have in total\n""")&lt;br /&gt;
    if answer == ("39"):&lt;br /&gt;
        your_name += ("sky")&lt;br /&gt;
        print ("Congratulations&lt;span style="color: Red;"&gt;&lt;/span&gt;,", your_name, ". You're smart!")&lt;br /&gt;
        answer_dos = input("Would you like to see the solution?")&lt;br /&gt;
        if answer_dos == ("yes"):&lt;br /&gt;
            print """&lt;br /&gt;
            We have the mother and father duck, the three ducklings and their&lt;br /&gt;
            spouses, and the thirty grand-ducklings, a total of 39 ducks.&lt;br /&gt;
            """&lt;br /&gt;
        else:&lt;br /&gt;
            print ("So long then!")&lt;br /&gt;
    else:&lt;br /&gt;
        print ("You are terrible at math.")&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
okay, all the things hi-lighted in red are the things that python is saying is a syntax error. the indenting is not right because i copied and pasted it, but you guys get the general idea:&lt;br /&gt;
&lt;br /&gt;
import random&lt;br /&gt;
&lt;br /&gt;
your_name = input("What is your name?")&lt;br /&gt;
nicknames = ("Fruitcup", "Captain", "Bunny", "Mama", "Dummkopf")&lt;br /&gt;
nickname = random.choice(nicknames)&lt;br /&gt;
or_not = input("Do you mind if I call you", nickname, "?")&lt;br /&gt;
if or_not == ("yes"):&lt;br /&gt;
    print ("Fine then,", your_name, ".")&lt;br /&gt;
    answer = input("""&lt;br /&gt;
    Answer this then,""", your_name, """:&lt;br /&gt;
    \tIf two ducks have 5 ducklings, and three of those ducklings have\n&lt;br /&gt;
    \t10 ducklings each, how many ducks do you have in total\n""")&lt;br /&gt;
    if answer == ("39"):&lt;br /&gt;
        your_name += ("sky")&lt;br /&gt;
        print ("Congratulations,", your_name, ". You're smart!")&lt;br /&gt;
        answer_dos = input("Would you like to see the solution?")&lt;br /&gt;
        if answer_dos == ("yes"):&lt;br /&gt;
            print """&lt;br /&gt;
            We have the mother and father duck, the three ducklings and their&lt;br /&gt;
            spouses, and the thirty grand-ducklings, a total of 39 ducks.&lt;br /&gt;
            """&lt;br /&gt;
        else:&lt;br /&gt;
            print ("So long then!")&lt;br /&gt;
    else:&lt;br /&gt;
        print ("You are terrible at math.")&lt;br /&gt;
&lt;br /&gt;
Like, what is up with that!!?!??!?!?!&lt;br /&gt;
&lt;br /&gt;
Okay, I'm pretty new to programming in general. I was a script kiddie with batch files and .vbs for a while, until i decided i wanted to do something besides making lame joke viruses and putting them on my sister's computer. I've had lots of problems so far, but i've been able to work through them all. Except for this. I've put hours into trying to fix this and nothing works. Please, i just need a little help. Even if you only know what not to do, but not nescesarily how to fix the problem, then by all means comment. any and all comments are appreciated. thanks!!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/408988/408988/crazy-weird-symtax-errors-please-help/</guid>
      <pubDate>Mon, 09 Nov 2009 14:02:32 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Crazy weird symtax errors, please help</title>
      <link>http://www.programmersheaven.com/mb/python/408988/409047/re-crazy-weird-symtax-errors-please-help/#409047</link>
      <description>I'm not sure why it's coming up as a syntax error w/o the indentation intact, but I can tell you that the input command is only designed to take one arg.  If you really wanna do some fancy string work, I recommend using %s as follows:&lt;br /&gt;
&lt;br /&gt;
or_not = input("Do you mind if I call you %s?" % nickname)&lt;br /&gt;
&lt;br /&gt;
%s lets you insert stuff into strings.  Your input command is interpreting input("stuff", variable, "moar stuff") as three args.  Using %s, you can jam it all into one, input-function-compatible string.  If you need multiple insertions, the stuff following the % must be a tuple:&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; print("%s, %s, %s" % (1, 2, 3))&lt;br /&gt;
1, 2, 3&lt;br /&gt;
&lt;br /&gt;
Also, if you want, you can name your string args:&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; print("%(s)s %(v)s %(o)s" % {'s': 'dogs', 'v': 'eat', 'o': 'birds'})&lt;br /&gt;
dogs eat birds&lt;br /&gt;
&lt;br /&gt;
The % does some other stuff, too, but I only ever use it with 's'.&lt;br /&gt;
&lt;br /&gt;
Also, the answer is 40 b/c the first ducks had 5 ducklings, not 3.&lt;br /&gt;
:P&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/408988/409047/re-crazy-weird-symtax-errors-please-help/#409047</guid>
      <pubDate>Tue, 10 Nov 2009 15:16:21 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Crazy weird symtax errors, please help</title>
      <link>http://www.programmersheaven.com/mb/python/408988/409050/re-crazy-weird-symtax-errors-please-help/#409050</link>
      <description>Okay, thanks for clearing up my math errors and telling me about %s.&lt;br /&gt;
That was reaaaaally helpful!&lt;br /&gt;
ANd I feel stupid now xD&lt;br /&gt;
Thanks again!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/408988/409050/re-crazy-weird-symtax-errors-please-help/#409050</guid>
      <pubDate>Tue, 10 Nov 2009 18:39:22 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Crazy weird symtax errors, please help</title>
      <link>http://www.programmersheaven.com/mb/python/408988/409052/re-crazy-weird-symtax-errors-please-help/#409052</link>
      <description>Okay, I reformatted it according to bubbatremell's suggestions (Thanks again!) and it is STILL doing crazy stuff:&lt;br /&gt;
&lt;br /&gt;
import random&lt;br /&gt;
&lt;br /&gt;
your_name = input("What is your name?")&lt;br /&gt;
nicknames = ("Fruitcup", "Captain", "Bunny", "Mama", "Dummkopf")&lt;br /&gt;
nickname = random.choice(nicknames)&lt;br /&gt;
or_not = input("Do you mind if I call you %s?" % nickname)&lt;br /&gt;
if or_not == ("yes"):&lt;br /&gt;
    print ("Fine then,", your_name, ".")&lt;br /&gt;
    answer = input("%(a)s %(b)s %(c)s" %{'a': "Tell me,", 'b': your_name, 'c': """:&lt;br /&gt;
    \tIf two ducks have 5 ducklings, and three of those ducklings have\n&lt;br /&gt;
    \t10 ducklings each, how many ducks do you have in total\n"""))&lt;br /&gt;
    if answer == ("50"):&lt;br /&gt;
        your_name += ("sky")&lt;br /&gt;
        print ("Congradulations,", your_name, ". You're smart!")&lt;br /&gt;
        answer_dos = input("Would you like to see the solution?")&lt;br /&gt;
        if answer_dos == ("yes"):&lt;br /&gt;
            print """&lt;br /&gt;
            We have the mother and father duck, the 5 ducklings and their&lt;br /&gt;
            spouses, and the thirty grand-ducklings, a total of 50 ducks.&lt;br /&gt;
            """&lt;br /&gt;
        else:&lt;br /&gt;
            print ("So long then!")&lt;br /&gt;
    else:&lt;br /&gt;
        print ("You are terrible at math. Goodbye!")&lt;br /&gt;
        input ("Please press the enter key to exit.")&lt;br /&gt;
else:&lt;br /&gt;
    print ("HORRAY!")&lt;br /&gt;
    answer = input("%(d)s %(e)s %(f)s" %('d': "Tell me,", 'e': nickname, 'f': """:&lt;br /&gt;
    \tIf two ducks have 5 ducklings, and three of those ducklings have\n&lt;br /&gt;
    \t10 ducklings each, how many ducks do you have in total\n"""))&lt;br /&gt;
    if answer == ("50"):&lt;br /&gt;
        nickname = your_name += ("sky")&lt;br /&gt;
        print ("Congradulations,", nickname, ". You're smart!")&lt;br /&gt;
        answer_dos = input("Would you like to see the solution?")&lt;br /&gt;
        if answer_dos == ("yes"):&lt;br /&gt;
            print """&lt;br /&gt;
            We have the mother and father duck, the 5 ducklings and their&lt;br /&gt;
            spouses, and the thirty grand-ducklings, a total of 50 ducks.&lt;br /&gt;
            """&lt;br /&gt;
        else:&lt;br /&gt;
            print ("So long, then.")&lt;br /&gt;
    else:&lt;br /&gt;
        print ("You are terrible at math.")&lt;br /&gt;
        &lt;br /&gt;
&lt;br /&gt;
All the stuff hi-lighted in red is stuff it's saying is a syntax error.&lt;br /&gt;
I mean, COME ON!!&lt;br /&gt;
Does anyone think that it might be something wrong with my version of python? Like, my comp screwed up the encoding or something?&lt;br /&gt;
Please get back to me on this!!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/408988/409052/re-crazy-weird-symtax-errors-please-help/#409052</guid>
      <pubDate>Tue, 10 Nov 2009 19:23:58 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Crazy weird symtax errors, please help</title>
      <link>http://www.programmersheaven.com/mb/python/408988/409053/re-crazy-weird-symtax-errors-please-help/#409053</link>
      <description>snap, I forgot to hilight.&lt;br /&gt;
Well, the syntax error were stuff like the word "you", the character %, and the quote marks ("").&lt;br /&gt;
Outrageous stuff.&lt;br /&gt;
I mean, seriously, something is up with my comp, and I have NO IDEA what it is!!!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/408988/409053/re-crazy-weird-symtax-errors-please-help/#409053</guid>
      <pubDate>Tue, 10 Nov 2009 19:26:11 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Crazy weird symtax errors, please help</title>
      <link>http://www.programmersheaven.com/mb/python/408988/409103/re-crazy-weird-symtax-errors-please-help/#409103</link>
      <description>answer = input("%(d)s %(e)s %(f)s" %('d': "Tell me,", 'e': nickname, 'f': """:&lt;br /&gt;
\tIf two ducks have 5 ducklings, and three of those ducklings have\n&lt;br /&gt;
\t10 ducklings each, how many ducks do you have in total\n"""))&lt;br /&gt;
&lt;br /&gt;
You declared the args to % as a tuple, and not as a dict.  You want a tuple for multiple unnamed args, and a dict for any number of named args.&lt;br /&gt;
&lt;br /&gt;
Also, it tends to help readability if you write out lists of things as such:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
answer = input("%(a)s %(b)s %(c)s" % {'a': "Tell me,",
                                      'b': your_name,
                                      'c': """:
\tIf two ducks have 5 ducklings, and three of those ducklings have\n
\t10 ducklings each, how many ducks do you have in total\n"""))&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Or something like that.  PEP8 insists that you limit your lines to 80 characters whenever possible, so breaking lists or arguments out to separate lines == pretty.&lt;br /&gt;
&lt;br /&gt;
I find that if I have a syntax error somewhere, it usually shows up somewhere besides where the actual error is.  This has to do with how Python is parsing your code.  It thinks that whatever you wrote is legitimate, but as something else.&lt;br /&gt;
&lt;br /&gt;
Also, the answer is 40. :)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/408988/409103/re-crazy-weird-symtax-errors-please-help/#409103</guid>
      <pubDate>Wed, 11 Nov 2009 11:47:52 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Crazy weird symtax errors, please help</title>
      <link>http://www.programmersheaven.com/mb/python/408988/409404/re-crazy-weird-symtax-errors-please-help/#409404</link>
      <description>Okay, this computer is just crazy. it's official.&lt;br /&gt;
My version of Python is officially considered messed up.&lt;br /&gt;
It keeps saying I have a syntax error, but it won't tell me what it is!!!&lt;br /&gt;
A window saying 'syntax error' pops up, but nothing is hi-lighted, and nothing looks out of place!!!&lt;br /&gt;
Come on!!!&lt;br /&gt;
now, you cannot say that Python is interpreting THAT wrong.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/408988/409404/re-crazy-weird-symtax-errors-please-help/#409404</guid>
      <pubDate>Mon, 16 Nov 2009 19:53:42 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Crazy weird symtax errors, please help</title>
      <link>http://www.programmersheaven.com/mb/python/408988/409526/re-crazy-weird-symtax-errors-please-help/#409526</link>
      <description>I'll take another look if you wanna paste code w/ all indentation and what version of python you are using.  It can't be debugged w/o indentation.  Don't worry if it doesn't show up quite right on the page-- I can always hit view page source. As long as it's there :)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/408988/409526/re-crazy-weird-symtax-errors-please-help/#409526</guid>
      <pubDate>Wed, 18 Nov 2009 11:34:44 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Crazy weird symtax errors, please help</title>
      <link>http://www.programmersheaven.com/mb/python/408988/409816/re-crazy-weird-symtax-errors-please-help/#409816</link>
      <description>Okay...&lt;br /&gt;
&lt;br /&gt;
First off, I switched from python 3.0.1 to 2.6.4 . Seemed like a more stable version, and I thought it might help me out with these crazy errors.&lt;br /&gt;
So, I went ahead and downloaded that.&lt;br /&gt;
It seemed to be working better (some programs that were not working before started to) until I tested this code.&lt;br /&gt;
It's coming up with more crazy syntax errors, and it's driving me up the wall!&lt;br /&gt;
&lt;br /&gt;
Okay, here's the code, and all the stuff that's supposedly a syntax error is hilighted in red:&lt;br /&gt;
&lt;br /&gt;
#Programmed by EmoIrish37, 7/30/09&lt;br /&gt;
&lt;br /&gt;
import random&lt;br /&gt;
&lt;br /&gt;
your_name = input("What is your name?")&lt;br /&gt;
nicknames = ("Fruitcup", "Captain Cupcakes", "Bunny", "Kid", "Dummkopf")#Haha...&lt;br /&gt;
nickname = random.choice(nicknames)&lt;br /&gt;
or_not = input("Do you mind if I call you %s?" % nickname)&lt;br /&gt;
if or_not == ("yes"):&lt;br /&gt;
    print ("Fine then,", your_name, ".")&lt;br /&gt;
    answer = input("%(a)s %&lt;span style="color: Red;"&gt;(&lt;/span&gt;b)s %(c)&lt;span style="color: Red;"&gt;s&lt;/span&gt;" %{'a': "Tell me,",&lt;br /&gt;
                                         'b': your_name,&lt;br /&gt;
                                         'c': """:&lt;br /&gt;
                                         \tIf two ducks have &lt;br /&gt;
                                         ducklings, and three of those&lt;br /&gt;
                                         have ten ducklings each, how &lt;br /&gt;
                                         many ducks do you have in&lt;br /&gt;
                                         total?(Hint: ONLY the ducks&lt;br /&gt;
                                         WITH CHILDREN are &lt;br /&gt;
                                         married.)"""))&lt;br /&gt;
    if answer == ("40"):&lt;br /&gt;
        your_name += ("sky")&lt;br /&gt;
        print ("Congradulations,", your_name, ". You're smart!")&lt;br /&gt;
        answer_dos = input("%(a)s %(b)s %(c)s" %{"a" = "&lt;span style="color: Red;"&gt;W&lt;/span&gt;ould &lt;span style="color: Red;"&gt;y&lt;/span&gt;ou"&lt;br /&gt;
                                                 "b" = " like to see"&lt;br /&gt;
                                                 "c" = " the answer?"})&lt;br /&gt;
        if answer_dos == ("yes"):&lt;br /&gt;
            print """&lt;br /&gt;
            We have the mother and father duck, the 3 ducklings and&lt;br /&gt;
            their spouses, and the thirty grand-ducklings, a total of &lt;br /&gt;
            40 ducks.&lt;br /&gt;
            """&lt;br /&gt;
        else:&lt;br /&gt;
            print ("So long then!")&lt;br /&gt;
    else:&lt;br /&gt;
        print ("You are terrible at math. Goodbye!")&lt;br /&gt;
        input ("Please press the enter key to exit.")&lt;br /&gt;
else:&lt;br /&gt;
    print ("HORRAY!")&lt;br /&gt;
    answer = input("%(d)s %(e)s %(f)s" %('d': "Tell me,",&lt;br /&gt;
                                         'e': nickname,&lt;br /&gt;
                                         'f': """:&lt;br /&gt;
                                         \tIf two ducks have&lt;br /&gt;
                                         five ducklings, and&lt;br /&gt;
                                         three of those ducklings have&lt;br /&gt;
                                         ten ducklings each, how many &lt;br /&gt;
                                         ducks do you have in&lt;br /&gt;
                                         total? Hint: ONLY the ducks&lt;br /&gt;
                                         WITH CHILDREN are&lt;br /&gt;
                                         married.)"""))&lt;br /&gt;
    if answer == ("40"):&lt;br /&gt;
        nickname = your_name += ("sky")&lt;br /&gt;
        print ("Congradulations,", nickname, ". You're smart!")&lt;br /&gt;
        answer_dos = input("Would you like to see the solution?")&lt;br /&gt;
        if answer_dos == ("yes"):&lt;br /&gt;
            print """&lt;br /&gt;
            We have the mother and father duck, the 5 ducklings&lt;br /&gt;
            and their spouses, and thirty grand-ducklings, a total of&lt;br /&gt;
            40 ducks.&lt;br /&gt;
            """&lt;br /&gt;
        else:&lt;br /&gt;
            print ("So long, then.")&lt;br /&gt;
    else:&lt;br /&gt;
        print ("You are terrible at math.")&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ugh, sorry, I couldn't get the indentation to work. If you need me to email the code or the file to you, that works too. My email is.. Well, we'll see if it comes to that ;)&lt;br /&gt;
Thanks again!&lt;br /&gt;
        &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/408988/409816/re-crazy-weird-symtax-errors-please-help/#409816</guid>
      <pubDate>Tue, 24 Nov 2009 15:49:59 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Crazy weird symtax errors, please help</title>
      <link>http://www.programmersheaven.com/mb/python/408988/409817/re-crazy-weird-symtax-errors-please-help/#409817</link>
      <description>Oh, and by the way, I'm pretty sure the answer is 40.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/408988/409817/re-crazy-weird-symtax-errors-please-help/#409817</guid>
      <pubDate>Tue, 24 Nov 2009 15:57:39 -0700</pubDate>
      <category>Python</category>
    </item>
  </channel>
</rss>
