Note that there are some explanatory texts on larger screens.

plurals
  1. POSyntax error with basic Python 3 issue
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/826948/syntax-error-on-print-with-python-3">Syntax error on print with Python 3</a> </p> </blockquote> <p>I know Python is supposed to be the god of interpreted languages... its simplicity, its lack of redundancy, blah blah blah. But since I'm too used to C, C++, Java, Javascript and Php, I must admit this is annoying. Here's my code:</p> <pre><code>#!/usr/bin/python3.1 def shit(texture, weight): if textura is "green": texturaTxt = "Shit is green" elif textura is "blue": texturaTxt = "Shit is blue" elif textura is "purple": texturaTxt = "Shit is purple" else: print "Incorrect color" break if weight &lt; 20: pesoTxt = " and weights so few" elif weight &gt;= 20 and peso &lt;=50: pesoTxt = " and weights mid" elif weight &gt; 50: pesoTxt = " and weights a damn lot" else: print "Incorrect weight" return texturaTxt + pesoTxt c = input("Introduce crappy color: ") e = input("Introduce stupid weight: ") r = shit(c, w) print r </code></pre> <p>I'm trying to learn Python and what I was trying to achieve was:</p> <pre><code>... function shit(texture, weight) { string textureTxt = "Shit is ", pesoTxt = " and weights "; switch(texture) { case "green": textureTxt .= "green as an applee"; break; case "blue": textureTxt .= "blue as the sky"; break; case "purple": textureTxt .= "purple as Barny"; break; default: cout&lt;&lt;"Incorrect texture, try again later" &lt;&lt;endl; exit; } //etc } string color = ""; int weight = 0; cout&lt;&lt;"Introduce color: "; cin&gt;&gt;color; //etc cout&lt;&lt;shit(color, weight); ... </code></pre> <p>But I give up, I can't make it work, it throws my all kind of errors. Hope there is some C++ or php or C to python converter out there.</p> <p>Thanks for your help</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload