Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed last year.
This post was edited and submitted for review 9 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I'm trying to make a game in python and am organizing my data.
game={
'img':{
'bg':'wouir'
}
}
print(stuff.img.bg)
When I push build it has an error on the last line saying:
AttributeError: 'dict' object has no attribute 'img'
It seems I have a problem, what is it?
You cannot access object's items through dot-notation in Python. You're supposed to use braces.
screen.draw(game["img"]["bg"], (0,0))
In Python, the keys of a dictionary are not its attributes. This means you cannot call them with the .. You have to use ['img'] instead of .img.
Change your loop to this:
while True:
screen.draw(game['img']['bg'], (0,0)) # I've only corrected game.img.bg
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
s = [1,2,3,4]
list(map(lambda parameter : parameter*2, s))
I am trying to run this simple line of code, but ending up getting
TypeError: 'list' object is not callable
can anybody please suggest me a solution for this
Your code works as is. I'm guessing (for lack of info) that somewhere above these lines of code you've overridden list as an actual list...
Check your code for this kind of error, and if it exists then refactor and rename so as to not use list as a parameter in your code.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
https://github.com/AZHenley/teenytinycompiler.git
Can you get this to run I got it from this website:
http://web.eecs.utk.edu/~azh/blog/teenytinycompiler1.html
I followed this tutorial and it failed to load the source file.
I am new to python.
this is a screenshot of when I ran the python project
You never pass in the source file. The command you have now only starts the TeenyTiny compiler. You can pass in the source file as follows.
"C:/Users/Ackeem/AppData/Local/Programs/Python/Python39/python.exe" "C:/Users/Ackeem/Desktop/teenyTIny Compiler/teenytinycompiler/part2/teenytiny.py" "C:/Users/Ackeem/Desktop/teenyTIny Compiler/teenytinycompiler/part2/hello.tiny"
Your code did run but there were no parameters passed to it.
sys.argv is the object that holds parameters being passed.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I have a dataframe called propertydf.
When I run my code I get a very vague error:
propertydf = propertydf[propertydf['fixed_price'].notna()].copy()
^
SyntaxError: invalid syntax
I checked the code and the dataframe variable has changed color to blue? But not all of them.
I also noticed some other variables are suddenly blue, such as year and date.
I think this is causing the error. How can I fix it?
In the line propertydf['fixed_price'] = fix_price((propertydf.iloc[:,[4]]) you open two parenthesis but only close one (It's above the line that throws the error).
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm trying to exactly what is described here and seems straightforward enough:
Add 2 hours and 1 day onto a timestamp in django
Here is my code:
new_event.EventDate += timedelta(hours = int(standard_time_offsets[request.user.member.timezone]))
new_event.save
print new_event.EventDate
The print statement returns the correctly adjusted date but when I check the record it has reverted to its value prior to the save. Im stumped, all help is greatly appreciated.
You don't call the save() method. The code should be:
new_event.save()
Note the parenthesis.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
When I try to create and write to a text file only an empty file is created. Here is the code:
controlCheck = open("resources/controlType.txt", "w")
controlCheck.write("controller")
controlCheck.close()
Any idea what the problem is? Its driving me crazy.
Whenever python writes a file, it erases all former data.There are ways to get around it, such as using: what is talked about here: Opening a file for append