Skip to content

Commit ddf1ad1

Browse files
authored
Merge pull request #14 from aviiciii/update
Update Logic in Meal and Plates
2 parents f2a337c + bf7f9b9 commit ddf1ad1

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

pset1/meal.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
def main():
22
in_time = input('What time is it? ').strip()
33
time = convert(in_time)
4+
# print(f'{in_time} converts to {time:.2f}')
45
if 7 <= time and time <= 8:
56
print('breakfast time')
67
elif 12 <= time and time <= 13:
@@ -14,18 +15,18 @@ def convert(time):
1415
if time.rfind('a.m.') != -1:
1516
time= time[:time.rfind('a')]
1617
hours, minutes = time.split(':')
17-
converted_time = float(hours)+(float(minutes)/600)
18+
converted_time = float(hours)+(float(minutes)/60)
1819
return converted_time
1920

2021
elif time.rfind('p.m.') != -1:
2122
time= time[:time.rfind('p')]
2223
hours, minutes = time.split(':')
23-
converted_time = 12+float(hours)+(float(minutes)/600)
24+
converted_time = 12+float(hours)+(float(minutes)/60)
2425
return converted_time
2526

2627
else :
2728
hours, minutes = time.split(':')
28-
converted_time = float(hours)+(float(minutes)/600)
29+
converted_time = float(hours)+(float(minutes)/60)
2930
return converted_time
3031

3132

pset2/plates.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@ def is_valid(s):
2626
first_num = s.index(character)
2727
break
2828
# check if there is no alphabet after first num
29-
for character in s:
30-
if s.index(character)<= first_num:
31-
pass
32-
else:
33-
if character.isalpha():
34-
return False
35-
#all conditions satisfied
29+
for character in s[first_num:]:
30+
if character.isalpha():
31+
return False
32+
# all conditions satisfied
3633
return True
3734

3835

0 commit comments

Comments
 (0)