## Pyschools Topic 3 Q 9

I'm new to programming and I was trying out this question on Pyschools.

Can anyone help me?

Write a function that converts the time to 24hr format. Examples

```>>> time24hr('12:34am')
'0034hr'
>>> time24hr('12:15pm')
'1215hr'
```

This question is under conditionals.

1. Remove the "am" or "pm" from the end and save it off somewhere
2. Split on the ":", so you have hours and minutes separate
3. If the time is "am", print the hour unless the hour is "12", in which case print "00"
4. Otherwise (if the time is "pm"), print the hour + 12 unless the hour is "12", in which case print "12"
5. Print the minutes

I'm new to programming and I was trying out this question on Pyschools. Can anyone help me? Write a function that converts the time to 24hr format. Examples​. I am new to Python and i jumped right into python 3. However i am trying to use the learning practices from pyschools.com. I have run into a question that deals with using strings. They want this result: "No, thanks, Mom," I said, "I don't know how long it will take.".

```def time24hr(tstr):
time_list = tstr[:-2].split(':')
time_int = [int(x) for x in time_list]
am_pm = tstr[-2:]
hours = time_int
minutes = time_int
if am_pm == 'am':
if hours < 12:
hours = hours + 12
return "%02d%02dhr" % (hours,minutes)
else:
return "00%2dhr" % (minutes)
else:
if hours < 12:
hours = hours + 12
return "%02d%02dhr" % (hours,minutes)
else:
return "%02d%02dhr" % (hours,minutes)
```

Topic 3 Q 9 Pyschools. script.py. def time24hr(tstr):. x=tstr[-2:] y=tstr.split(':'). z=y​. global v. v=y. global b. global c. global total. if x== "am": b=v.split("a"). c=b. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Pyschool Topic 11: Q 13. Ask Question

```def time24hr(tstr):
newTime = ""
if "am" in tstr:
for i in tstr:
if i not in ":am":
newTime += i
if "12" in newTime[:2]:
newTime = newTime.replace("12", "00")
return newTime + "hr"
elif len(newTime) == 3:
newTime = "0" + newTime + "hr"
return newTime
elif "pm" in tstr:
for i in tstr:
if i not in "pm":
newTime += i
if "10" in newTime[:2]:
newTime = newTime.replace("10", "22")
newTime = newTime.replace(":", "")
elif "11" in newTime[:2]:
newTime = newTime.replace("11", "23")
newTime = newTime.replace(":", "")
elif "12" in newTime[:2]:
newTime = newTime.replace(":", "")
elif "1" in newTime[:1]:
newTime = newTime.replace("1", "13")
newTime = newTime.replace(":", "")
elif "2" in newTime[:1]:
newTime = newTime.replace("2", "14")
newTime = newTime.replace(":", "")
elif "3" in newTime[:1]:
newTime = newTime.replace("3", "15")
newTime = newTime.replace(":", "")
elif "4" in newTime[:1]:
newTime = newTime.replace("4", "16")
newTime = newTime.replace(":", "")
elif "5" in newTime[:1]:
newTime = newTime.replace("5", "17")
newTime = newTime.replace(":", "")
elif "6" in newTime[:1]:
newTime = newTime.replace("6", "18")
newTime = newTime.replace(":", "")
elif "7" in newTime[:1]:
newTime = newTime.replace("7", "19")
newTime = newTime.replace(":", "")
elif "8" in newTime[:1]:
newTime = newTime.replace("8", "20")
newTime = newTime.replace(":", "")
elif "9" in newTime[:1]:
newTime = newTime.replace("9", "21")
newTime = newTime.replace(":", "")
return newTime + "hr"
```

Hi there,. So I'm trying to do the Risk Game question on Pyschools.com ((Topic 3, Question 12) can be seen here: http://  QI is a British comedy panel game television quiz show created and co-produced by John Lloyd, and features permanent panellist Alan Davies. Stephen Fry was h

For me it works (but it isn't too pretty :'C):

```def time24hr(tstr):
a=list(tstr)
if len(a)==6:
a.insert(0,'0')
if a=='a' and a=='1' and a=='2':
del a
del a[4:6]
a.append('h')
a.append('r')
a='0'
a='0'
w=''.join(a)
return w
elif a=='p':
del a
del a[4:6]
a.append('h')
a.append('r')
x=a+a
print x
y=int(x)
print y
if y<12:
z=y+12
g=str(z)
a[0:2]=g
w=''.join(a)
return w
else:
w=''.join(a)
return w
else:
del a
del a[4:6]
a.append('h')
a.append('r')
w=''.join(a)
return w
```

Message 1 of 9 Message 2 of 9 As you'll notice, your Topic is now in the Programming Help and Discussion board. Message 3 of 9  Runs on Google App Engine Python runtime environment. Uses Python version 2.7. Includes the Python standard library, but some features such as networking and threading are not supported. os module is disabled for this application. PySchools Doc

```def time24hr(s):
c = s.split(':') # Split string to list ["hh", "mmAP"] AP is "am" or "pm"
h = int(c) # convert hours string to integer
m = int(c[0:-2]) # remove "AP" from "mmAP" and convert to integer. This will handle "mAP" input correctly as well.
h = h % 12 if s[-2:] != 'pm' else 12 if h == 12 else h + 12 # convert hours to 24hr format, handling edge cases.
return "%02d%02dhr" % (h, m) # Print hours and minutes as %02d - two digits, potentially filling with zeroes
```

Vegye ki a „am” vagy „pm” a végére, és mentse el valahová; Split a „:”, így van az órát és percet külön; Ha az idő „AM”, kinyomtatni az óra, kivéve, ha az óra „12”,  Q9 Quality Risk Management June 2006. Guidance Issuing Office. Office of Medical Products and Tobacco, Center for Drug Evaluation and Research. Office of Medical Products and Tobacco, Center for

Click to show 3 solutions. Similar Question 2 : pyschools topic 3 ex 9. I have made Similar Question 3 : pyschools Topic 3 Q 6. I'm trying to  Los Prisioneros - Topic 32,941 views 5:04 Lo Mejor de los 90's Mana - Cafe Tacuba - Enrique Bunbury - Soda Stereo - Enanitos Verdes MIX EXITOS - Duration: 1:31:05.

let date = Date() let calend 3 years ago Pyschools Topic 3 Q 9 I'm new to programming and I was trying out this question on Pyschools. Can anyone  Q&A is looking for citizens to tackle the big questions alongside Tony Jones and our panellists. Register here. Get in touch with the Q&A production team, or subscribe to the Q&A newsletter

Come and see the site and domain statistics for pyschools.com such as IP, Domain, Whois, .js, http://1-ps.googleusercontent.com/xk/rjJT-​o5D8mDUiRwdvHSR-9-Uu1/s. python - Pyschools Topic 3 Q 11 - DNA parity check - Stack Overflow  (topic 5 - q 4 at pyschools.com) My code: def addNumbers(x): finalsum = list() theSum = 0 i = 1 while i <= x: theSum = theSum + i i = i + 1 finalsum.append(theSum) return finalsum