[code]
>>> result = 1
>>> while result < 1000:
result *= 2
print result
SyntaxError: invalid syntax (<pyshell#3>, line 3)[/code]1. why does this line (while result < 100: ) need the colon :
2. what does result *= 2 really mean?
3. why do I get a syntax error :/
[B]EDIT: t0rento is right ! solution found [/B]
*= means the same as Result = result * 2
[editline]12:33AM[/editline]
i don't know about the other stuff
1. Because it's a loop.
2. result = result * 2
3. I have no idea but in Python you have to indent loops and conditions, that might be it.
ok..that still doesn't explain the weird syntax error..
I got this codes off a book btw.so it shouldn't be wrong
so much for python being easy to learn..
hell the community is dead too
1. It's a loop.
2. I don't know. I think it might mean result = result * 2
3. Because you didn't indent or result *=2 isn't valid are the only reasons I could gather.
Indent, and if it still doesn't work try typing "result = result * 2" instead of "result *=2"
It's not. You're looking in the wrong place. And it [i]is[/i] easy to learn. But that doesn't mean you don't have to put some effort in it.
Considering how sensitive python is to formatting, and depending on your version it might need to look like this:
[code]
result = 1
while (result < 1000):
result *= 2
print( result )
[/code]
In python v3 print requires the parenthesis, unsure with while but it's likely that it does.
The book's code is probably from an older version of python.
[IMG]http://content.screencast.com/users/nineminutes/folders/Jing/media/1f9c0518-f130-4ff1-b680-201c4501252e/2010-03-21_1911.png[/IMG]
this is the error that I got so I don't think it's result that is causing the error..
[B]
EDIT:t0rento is right !! solution found many thanks[/B]
If you think python's community is dead, then you're not looking.
[QUOTE=Ortzinator;20889165]If you think python's community is dead, then you're not looking.[/QUOTE]
I've googled "python forum" "good python forum" and gone through a few pages..
The only place I've found is the official forum
[QUOTE=XIII_GT;20890708]I've googled "python forum" "good python forum" and gone through a few pages..
The only place I've found is the official forum[/QUOTE]
What's wrong with the official forums? Also, #python on Freenode.
I'm also very willing to help with python problems, along with several other people here. Seeing as this isn't a massively active programming forum, the fact that you can find people to help you indicates that python is a very much active language.
Yes, I am a bit of fan boy, whatever makes you say that? ;)
I'll keep those in mind, thanks guys.
also Theboff can I add you on msn?
Erm, I'd rather you just pm me.
lol sure that works too :p thanks again
Just a tip : your book is giving perfectly valid 2.x code, use that interpreter instead of 3.x
Sorry, you need to Log In to post a reply to this thread.