Tagged Questions
0
votes
2answers
25 views
How can I add a score to my game? [on hold]
Just wondering how I could add a score in this game I made?
I don't understand how I can add a score that will add one every time someone gets a question right. I've tried many ways however I don't ...
0
votes
3answers
37 views
recursive function in python adding?
So the question reads: Design a function that accepts an integer argument and return’s the sum of all integers from 1 up to the number passed as an argument. For example, if 50 is passed as an ...
1
vote
1answer
160 views
Trying to add a number to a variable in Python, keeps resetting the variable back to what it was originally [closed]
def start():
number = 0
prompt = raw_input("> ")
if prompt == "1":
number += 1
print number
start()
else:
start()
start()
My output:
Enter ...
1
vote
1answer
67 views
Adding in python2
This is a check digit exercise.
A=str(56784321)
for x in [0,2,4,6]:
B = int(A[x])*2
if len(str(B))==2:
B = int(str(B)[0])+int(str(B)[1])
print (B)
Output:
1
5
8
...
1
vote
3answers
249 views
Adding in python
while i<10:
a = a + i
print (a)
i = i+1
or
for i in range(10):
sum = sum + i
print
0
1
3
6
10
15
21
28
36
45
Then how can I add them together by writing further codes?
I ...
3
votes
2answers
1k views
Python: retrieve dictionary keys in order as added?
In Python, is there a way to retrieve the list of keys in the order in that the items were added?
String.compareMethods = {'equals': String.equals,
'contains': ...
2
votes
3answers
2k views
Adding data to a csv file through Python
I've got a function that adds new data to a csv file. I've got it somewhat working. However, I'm having a few problems.
When I add the new values (name, phone, address, birthday), it adds them all ...
0
votes
3answers
816 views
Parsing a Comma Delimited File With Python and adding currency fields
I'm trying to use Python to parse a comma delimited file with a layout similar to this:
AccountNumber,Invoice_Number,Gross_Amt,Adjustments,TotalDue
"234","56787","19.37",,"19.37"
...
31
votes
2answers
10k views
Why can't you add attributes to object in python?
(Written in Python shell)
>>> o = object()
>>> o.test = 1
Traceback (most recent call last):
File "<pyshell#45>", line 1, in <module>
o.test = 1
AttributeError: ...