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 7 years ago.
Improve this question
On codacy it detects an issue where I dont have enough arguments for format string. Help please.
code:
self.notify.error("An item we don't have: track %s level %s was selected." % [track, level])
pass a tuple, not a list
self.notify.error("An item we don't have: track %s level %s was selected." % (track, level))
this is how i fixed it
"An item we don't have: track {} level {} was selected.".format(track, level)
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 6 months ago.
Improve this question
import math
import random
possibility_1=0
possibility_2=0
while True:
list = [0, 1]
number_1=random.choice(list)
number_2=random.choice(list)
number_3=random.choice(list)
number_total=str(number_1)+","+str(number_2)+","+str(number_3)
if number_total==(1,1,0) or number_total==(0,0,1):
possibility_1 +=1
if number_total==(1,1,1) or number_total==(0,0,0):
possibility_2 +=1
print(str(number_total)+" possibility_11= "+ str(possibility_1)+" possibility_12= "+ str(possibility_2))
guys the possibility_1 and possibility_2 doesn!t changing. Please help me I want to make a heads or tails code and simulate it then check the possibilities.
Looks like number_total is a string so the output would be "1,1,0" you are comparing with a tuple. This means the if statements will not be invoked.
if number_total=="1,1,0" or number_total=="0,0,1":
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 3 years ago.
Improve this question
In my code below, the times variable prints data in calendar and business time. Some of the data have numbers and others print the value 'None'. I would like to only print data that does not have the value 'None'. When I run my code I still get all of the data printed.
for ticket1 in ticket_list1:
for ticket2 in ticket_list2:
times = ticket2['reply_time_in_minutes']
ticket_id = ticket2['ticket_id']
assignee = ticket1['assignee_id']
priority = ticket1['priority']
if ticket1['assignee_id'] != ticket1['requester_id']:
if times['calendar'] != 'None':
print("%s %20s %20s %20s" % (times, ticket_id,
assignee, priority))
Remove the quotes around none. None is actually a value - of <type 'NoneType'>. So it cannot be compared to a string.
if times['calendar'] != None:
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 5 years ago.
Improve this question
Hello I have an error with the code below. I am trying to print "Bus num: "busnum. busnum is data taken from a excel sheet. Can someone explain to me why this invalid syntax as well as ways to improve to that part of the code?
for busnum,change in busses_in_year[location]:
print('Bus #: 'busnum)
I believe you wanted to use string formatting. See below:
for busnum,change in busses_in_year[location]:
print('Bus #: %d' % busnum)
Or you could simply do print("Bus #:" + str(busnum))"
Either way you can't just stick it onto the end there. You have to add it or format it in.
Or you can just use 'comma'.
print('Bus #: ', busnum)
Instead of
print('Bus #: 'busnum)
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 6 years ago.
Improve this question
In Python 2.7, the function bytearray.fromhex(string) gives:
ValueError: non-hexadecimal number found in fromhex() arg at position x
when the string has '16' in it, like in for example:
0200FF001603000E30D03, 0200FF001603004401A03
It's like failing if it was decimal and was '84102' just for having '10', the base, in it.
How can I avoid that error?
There is no problem with 16 existed in the string, the problem is that you try to encode odd length strings - try any valid string with even length and you will see that it is works.
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 7 years ago.
Improve this question
I'm trying to make a simple console game in Python 2.7, where the user gets a dilemma and makes a decision by typing the number correlating to the option he wants to choose. This question is the main menu.
s = raw_input("Enter a number in the range 1 to %s\n> " % v
if (is_number(s) and s in q):
return s
I'm getting a "SyntaxError: Invalid syntax" from the if (is_number(s) and s in q) statemet when trying to run the program. It was working fine before i added the question.
This is my first real program.
You're missing a parentheses on the previous line:
s = raw_input("Enter a number in the range 1 to %s\n> " % v
# here--^