0
votes
1answer
32 views

Syntax error for input() [duplicate]

So I'm new to python and was doing this python prog for an online coding site.the problem is when i run my code in IDLE it compiles perfectly and gives the correct output but when i run it in the ...
0
votes
3answers
23 views

Issues with invalid syntax error in a url

In my code Im trying to get the user to log in and retrive some information, but I get a syntax error with my variables user and password. bold print is commented out in code import urllib.request ...
-1
votes
0answers
58 views

Python Syntax — variable with a text string [on hold]

UPDATE: I resolved this issue - it was an issue with a capitalization of a variable earlier on. I am new to both python and stackOverflow so pardon any etiquette mistakes that i make. I am trying ...
0
votes
0answers
25 views

Python: Datagram error

As a test, I'm using datagrams for my Laughing Man head in my toontown server. However, it returns a syntax error. from direct.distributed.PyDatagram import PyDatagram from pandac.PandaModules import ...
1
vote
6answers
57 views

Python: Complete list with items

Let's say I have many lists. Each of these lists may have different length. The thing I want to do is to complete each of this lists with (for example) string "EMPTY". Is there a build-in function or ...
0
votes
2answers
20 views

Python MySQLdb error when trying to alter a table

I am trying to alter a database but I am not sure of the exact syntax and I am having trouble finding it online. The line that is giving the error is: cur.execute("ALTER TABLE Units ADD FOREIGN ...
1
vote
2answers
26 views

SyntaxError in Python IDLE 2.7 but not in PythonTutor

I'm getting a SyntaxError: invalid syntax in response to the following code when I run in it IDLE, but not in PythonTutor. Can anyone help with why? def apples(x, y): try: result = x/y ...
0
votes
1answer
31 views

Why can't I use the star operator like this? def foo(*args, this=“default”, **kwargs)

This would be fun: def foo(*args, this="default", **kwargs): pass but File "foo.py", line 1 def foo(*args, this="default", **kwargs): ^ SyntaxError: invalid syntax ...
0
votes
2answers
37 views

Complex “=” statement, rating, created = Vote.objects.get(**kwargs), False

I've done an extensive search for the answer but can't figure out how to properly search for the answer to the meaning of the following line of code: rating, created = Vote.objects.get(**kwargs), ...
-1
votes
1answer
34 views

Syntax error when using “with..as” [closed]

I have a syntax error in the line: with contextlib.closing(urllib2.urlopen("http://" + url) as hh: The error points to the keyword "as". File "/Users/david/Desktop/getaurl.py", line 14 with ...
-4
votes
1answer
52 views

What does (foo, bar) = foobar() Python syntax mean? [duplicate]

What does (foo, bar) = foobar() mean in Python? The original question doesn't explain () on the left of the =, unless you already know the answer and the title is ambiguous
-3
votes
2answers
61 views

Im new to pyhon and I keep getting an error can any one help me? [closed]

So I have been given a python booklet to follow from my first GCSE computer science lesson. and one tasks asks me to improve the efficiency of this code using and, or and not operators: ...
3
votes
3answers
57 views

Cant understand some python tuple syntax

I started learning python today and found this very nice code visualization tool pythontutor.com, the problem is that I still don't quite get some of the syntax on the example code. def ...
0
votes
1answer
33 views

Python Error: Cannot access function in class

I've started working with python recently and am totally confused. I have the following class: class Vault: def __init__(self): # used to mock collection (table) of ads self._ads = [ { ...
-2
votes
3answers
56 views

in Python 2.7.5, why is “if (code)” valid syntax but “elif (same code)” isn't? [closed]

here is the entire module. All the "elif" statements are valid syntax if changed into "if" statements def processRGB(item, matrix): threshhold = 229 red, green, blue = matrix[0, 0] if red ...
-1
votes
1answer
39 views

Syntax Error In Python Function [closed]

I have checked everything that I could to try and fix this code. It may just be something stupid that I didn't see but I literally learned this language today. I keep getting invalid syntax. Can ...
-5
votes
2answers
40 views

Python IndentationError - How to fix?

while loop == 6: if EVENTCOUNT >= 4: _, username, para, value = event.split(" ", 3) try: self.dbcur.execute('select ? from users where name = ...
1
vote
1answer
45 views

Boto Syntax Error?

I am importing boto.dynamodb.table and getting a syntax error. I don't see how it is related to what I'm doing. I haven't implemented / used it and yet upon launching it finds a syntax error. The ...
0
votes
0answers
17 views

Syntax error in visual studio

I started Udacity's Intro to Comp Sci course today, and generated this code at the end of the first lesson: page = '<a href="http://udacity.com">Hello world</a>' start_link = ...
2
votes
1answer
82 views

What does this line of Python code do?

I'm currently reading through a Python code repo and I'm not sure I understand this syntax: Sp = S[:Kp,:] Sc = S[Kp:,:] I'm guessing it has something to do with splicing but I'm not sure of how the ...
-3
votes
1answer
31 views

SPOJ FTHEELF in Python [closed]

I am kind of new to Python and I am trying to run this code but I am getting syntax error. Actually I just want to know why is there error while executing this code; is it because of input format or ...
2
votes
1answer
35 views

Import with a comma after the as

I was looking at a repo and came across a somewhat weird line from flask.ext.testing import TestCase as Base, Twill What does it mean to import like this? I have not seen it before and ...
-1
votes
2answers
30 views

python+raspberry pi gpio invalid syntax [closed]

i am doing an internship and i need to come up with a Raspberry Pi that will have a clicker to add subtract 1 and reset to 0 for how many days accident free for the company and the site, here is the ...
-1
votes
0answers
17 views

Syntax error on main class while loop for an updated block sprite.

import pygame, sys from pygame.locals import* pygame.init() class block(Object): def intitialize(self): x = 640 y = 360 vx = 2 vy = 2 size = (50, 3) ...
0
votes
2answers
43 views

Python def marked as invalid syntax [closed]

Im working on a (in-shell) geometry calculator in Python, and I get a syntax error everytime marked as the def in the below code: def scepm(r,h):#surface-area circular-prism(cylinder)comment s.o.f. ...
-3
votes
5answers
51 views

How to cube a number

I just started using Python today for my class and one of my problems is cubing a number in Python. I know the way to do it is x^3, but that doesn't work in Python. I was just wondering how I would be ...
0
votes
0answers
19 views

Highlighting ReST in python doc strings within vim

Since I am using Sphinx with autodoc I would like to have my vim highlight python docstrings with ReST syntax. Is that possible? Searching with google yielded only one usable result (I was surprised ...
1
vote
1answer
45 views

Python indentation error while loop

while x <= 9: result = usertype() if result == 'Correct': I am receiving an indentation error on the "t" of result in "result = usertype(). Can anybody explain this? *EDIT I have tried ...
2
votes
3answers
52 views

How does interval comparison work?

Somehow, this works: def in_range(min, test, max): return min <= test <= max print in_range(0, 5, 10) # True print in_range(0, 15, 10) # False However, I can't quite figure out the ...
0
votes
1answer
38 views

For Loop syntax error in code but not when separated

I'm making a program that is supposed to tell me what task I have to do next for school but it's giving me a wierd syntax error in a for loop. Here is the whole code: def dumptodaydate(): import ...
-2
votes
2answers
38 views

How can I replace values in one dictionary that are the keys of another

I have two dictionaries, one that stores country names and another that holds the respective country lat,long coordinates. I'd like to replace the values of path_dict with the values of the matching ...
-9
votes
1answer
59 views

Vending Machine Simulator Elif Statement Syntax Error [closed]

I am trying to make a vending machine simulator program but the program returns syntax errors on my elif statements as well as the colons in those statements. What is my issue? Here is my code: ...
1
vote
3answers
40 views

How to Alter a Dict's Values in a List Comprehension

I have a list of of dictionaries and my current list comprehension is separating the dictionaries (i.e., creating new dictionaries where they weren't previously). Here is some example code to help ...
0
votes
3answers
51 views

Mathematical expressions in Matplotlib 1.3.1

I am trying to write mathematical expressions in matplotlib.pyplot version 1.3.1 >>> import matplotlib >>> print matplotlib.__version__ 1.3.1 A snippet of the code that does ...
0
votes
0answers
28 views

how to turn on syntax in ipython notebook

I was using the python 2.7.5 and there is only simple syntax highlighting in my ipython notebook. All the key words like "for, if, import" are green and there is no highlighting for module like ...
-2
votes
1answer
25 views

How to use this code in python 3 version? [duplicate]

I want to run this code in the python 3 but i can't.Whenever i try to run the code,i get the invalid syntax error. age = 20 name = 'Swaroop' print '{} was {} years old when he wrote this ...
-3
votes
2answers
72 views

Python syntax error when defining a mapping [closed]

I am using python 2.7.4 on a Linux machine. My guide is the book "Learn Python the hard way" and I am at 39th exercise and here's my code: # states and their abberavation states = [ 'Bihar' : 'BIH' ...
1
vote
1answer
22 views

Syntax confusion about code in pip installer, “get-pip.py”

When looking at the pip installer get-pip.py found on this page I noticed a bit of syntax that I'm unfamiliar with. Found on line 17422 of the file, this is the line: packages += ["setuptools"] ...
1
vote
1answer
51 views

ImportError: No Module Named <parent dir>

I am trying to learn programming through Python, so I apologize in advance if this is an absurdly simple question. I am attempting to simplify my convoluted directory structure and utilize some of ...
-2
votes
1answer
37 views

Python Scrolling Game Syntax Error [closed]

I'm new to programming and I'm creating a scrolling game in which the player must avoid red blocks and collect green blocks. I am able to get the blocks to appear on the screen at random positions, ...
0
votes
1answer
30 views

Python - Syntax error with nested iterations? [closed]

SO I have this code: Chars = maketrans(" ABCDEFGHIJKLMNOPQRSTUVWXYZ-.,"," ABCDEFGHIJKLMNOPQRSTUVWXYZ-.,"); input = input.split(" "); length = len(input); charLength = len(Chars); for x in ...
1
vote
0answers
33 views

How to intercept a specific tuple lookup in python

I'm wondering how could one create a program to detect the following cases in the code, when comparing a variable to hardcoded values, instead of using enumeration, dynamically? class AccountType: ...
0
votes
1answer
51 views

understanding the python dictionary syntax

What is the difference between the following two syntax for a python dictionary? The first one gives me an error, the second doesn't. The key is text, just a description, and the value is a ...
-1
votes
1answer
27 views

can you store a python list and or beautiful soup ovject inside a python list

I am wondering in python can you; (1) store a list inside a list (2) store a beautiful soup (soup) object inside a list?
-2
votes
4answers
43 views

Syntax error 'continue' not properly in a loop [closed]

elif command == 'join': if len(params) < 1: continue safeexec(params[0], getattr(botimpl, 'onenter', None), (params[0], prefix)) it says Syntax error 'continue' not properly in a ...
0
votes
1answer
29 views

I cant run a while loop in python due to a syntax error [closed]

Can't solve a syntax error in this simple program. I don't see why after looking at many tutorials that it won't run. def wtf_whileloop(): return int(5) x=wtf_whileloop() while x=5: print ...
-7
votes
1answer
45 views

How to properly use Variables in Python Functions? [closed]

Building a random generator to determine the quality of gemstones. Running into a syntax error which is crashing the script... here's the code: import random # Set the basic parameters of the ...
1
vote
0answers
43 views

Calling Python Methods/Classes with square brackets [closed]

I am coming to Python from Matlab and mainly wish to use it for image analysis using the wrapped ITK libraries. Despite now being fairly familiar with basic Python function and class calling I can't ...
0
votes
5answers
37 views

Possible to simplify finding if an element exist in multiple lists?

This is my Python code, it's usable but... I'm sure there a way to simplify this long code. if partialAnswer in primaryTrees or partialAnswer in secondaryTrees or partialAnswer in tertiaryTrees: ...
-2
votes
2answers
43 views

Randomly Picking a number within a Range of 1-1680 [duplicate]

What I'm trying to do with this script is create cords for the mouse to travel too but I want the X cords to move to a location which is in the range of 0-1670. import win32api import win32con def ...