Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 9_for_exercise.py #230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions Basics/Exercise/9_for/9_for_exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,21 @@
# should tell you in which month that expense occurred. If expense is not
# found then it should print that as well.
print("\nExercise 3\n")
month_list = ["January", "February", "March", "April", "May"]
expense_list = [2340, 2500, 2100, 3100, 2980]
e = input("Enter expense amount: ")
e = int(e)

month_list = ['january','february','march','april','may']
expense_list = [2340,2500,2100,3100,2980]
month = -1
price = int(input('price: '))

for i in range(len(expense_list)):
if e == expense_list[i]:
if price == expense_list[i]:
month = i
break

if month != -1:
print(f'You spent {e} in {month_list[month]}')
print(month_list[month], expense_list[i])
else:
print(f'You didn\'t spend {e} in any month')

expense_list.append(price)
print(expense_list)
# 4. Lets say you are running a 5 km race. Write a program that,
# 1. Upon completing each 1 km asks you "are you tired?"
# 2. If you reply "yes" then it should break and print "you didn't finish the race"
Expand Down Expand Up @@ -77,4 +76,4 @@
s = ''
for j in range(i):
s += '*'
print(s)
print(s)