Tell us what’s happening:
I have a very rough code for the program but I’m getting an error that variable s is referenced before assignment. If anyone could help me regarding what I may be doing wrong or point me to what the problem may be. It is a very rough code and I do plan on refining it…
Your code so far
Your browser information:
User Agent is: Chrome/93.0.4577.82
Challenge: Time Calculator
Link to the challenge:
I’m not a python guy, but…
if day== None:
if l==0:
s=time+" "+str(ap)
elif l>0:
s=time+" "+str(ap)+str(days)
else:
if l==0:
s=time+" "+str(ap)+day
elif l==1:
s=time+" "+str(ap)+day+str(days)
return s
What if day is not equal to None
and l is 2? I think s never gets assigned.
1 Like
thats it! thanks!
thats solved but theres another issue now… the days are showing up as
<built-in method capitalize of str object at 0x7f54ddabf270>
so the answer when it needs to be 5:24 AM, Monday is:
5:24 AM<built-in method capitalize of str object at 0x7f54ddabf270>
ilenia
September 16, 2021, 3:15pm
#4
that seems to be as if you have concatenated a method to a string, when you wanted the output of the method
1 Like
so if I do the folowing, it wont work?
s=string.capitalize()
t="trial"+s
ilenia
September 16, 2021, 4:29pm
#6
you can add print(t)
to check the value
system
closed
March 18, 2022, 4:29am
#7
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.