hello i am trying to learn python i was doing ok
can somone please tell me why this don't work from
5.6 Looping Techniques
thanks
knights = {'gallahad': 'the pure', 'robin': 'the brave'}
for k, v in knights.iteritems():
print k, v
i get this error
19:18:02 M: 36392960 INFO: Q:\scripts\test.py
19:18:02 M: 36392960 INFO: ", line
19:18:02 M: 36392960 INFO: 13
19:18:02 M: 36392960 INFO:
19:18:02 M: 36392960 INFO:
19:18:02 M: 36392960 INFO: for k, v in knights.iteritems():
19:18:02 M: 36392960 INFO:
19:18:02 M: 36392960 INFO: ^
19:18:02 M: 36392960 INFO: SyntaxError
19:18:02 M: 36392960 INFO: :
19:18:02 M: 36392960 INFO: invalid syntax
ocwasere
Junior Member Posts: 31 Joined: Jul 2005 Reputation: 0 |
2007-04-07 20:36
Post: #1
|
| find quote |
ocwasere
Junior Member Posts: 31 Joined: Jul 2005 Reputation: 0 |
2007-04-07 21:43
Post: #2
got it to work from a funtion but
Code: knights={'gallahad': 'the pure', 'robin': 'the brave'} |
| find quote |
Nuka1195
Skilled Python Coder Posts: 3,917 Joined: Dec 2004 Reputation: 17 |
2007-04-07 22:15
Post: #3
indentation
|
| find quote |
ocwasere
Junior Member Posts: 31 Joined: Jul 2005 Reputation: 0 |
2007-04-07 22:31
Post: #4
Nuka1195 Wrote:indentation thanks for your reply i have had the indentation error and corrected it but this error is invalid syntax can i ask another quesion why doesn't a directory keep its order params = {"server":"mpilgrim", "database":"master", "uid":"sa", "pwd":"secret"} print params.items() [('pwd', 'secret'), ('database', 'master'), ('uid', 'sa'), ('server', 'mpilgrim')] |
| find quote |
ocwasere
Junior Member Posts: 31 Joined: Jul 2005 Reputation: 0 |
2007-04-08 02:25
Post: #5
ocwasere Wrote:why doesn't a directory keep its order found out why here Python Dictionaries don't have order |
| find quote |
ocwasere
Junior Member Posts: 31 Joined: Jul 2005 Reputation: 0 |
2007-04-08 02:35
Post: #6
please can you tell me whats wrong with the indentation of the code in red
Code: knights={'gallahad': 'the pure', 'robin': 'the brave'} |
| find quote |
stanley87
Skilled Python Coder Joined: Sep 2006 Reputation: 2 Location: Chch, New Zealand |
2007-04-08 02:44
Post: #7
get a great program called "PyScripter" - this checks ur code for syntax + indentation errors
:-) |
| find quote |
ocwasere
Junior Member Posts: 31 Joined: Jul 2005 Reputation: 0 |
2007-04-08 03:03
Post: #8
stanley87 Wrote:get a great program called "PyScripter" - this checks ur code for syntax + indentation errors thanks for the link, but i have not got python installed on my pc i am using notepad and the xbmc log file can you tell me whats wrong with the indentation for the code in red thanks |
| find quote |
Nuka1195
Skilled Python Coder Posts: 3,917 Joined: Dec 2004 Reputation: 17 |
2007-04-08 07:55
Post: #9
the code in red is commented out, so unless you post it the exact way you want, how could we possible tell you. maybe it's a mix of tabs and spaces.
|
| find quote |
ocwasere
Junior Member Posts: 31 Joined: Jul 2005 Reputation: 0 |
2007-04-08 12:29
Post: #10
Nuka1195 Wrote:the code in red is commented out, so unless you post it the exact way you want, how could we possible tell you. maybe it's a mix of tabs and spaces. thanks again for your reply to rephase my question should the for loop statement in red work if so can you tell me whats wrong with it thanks Code: knights={'gallahad': 'the pure', 'robin': 'the brave'} |
| find quote |

Search
Help