Possible Duplicate:
Syntax error on print with Python 3
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:
#!/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 < 20:
pesoTxt = " and weights so few"
elif weight >= 20 and peso <=50:
pesoTxt = " and weights mid"
elif weight > 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
I'm trying to learn Python and what I was trying to achieve was:
...
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<<"Incorrect texture, try again later" <<endl; exit;
}
//etc
}
string color = "";
int weight = 0;
cout<<"Introduce color: ";
cin>>color;
//etc
cout<<shit(color, weight);
...
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.
Thanks for your help