Skip to content

Commit c7a7b48

Browse files
Merge pull request #95 from paramgosar13-droid/paramplays
Fixed the typo and added bossbetter.py
2 parents 34f298c + 2ade953 commit c7a7b48

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

SOLUTIONS/paramgosar13-droid_solutions/test_playground/basics/boss.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
continue
1111

1212
flag = True # huh this seems inverted
13+
c=0
1314
for i in range(1,len(numbers)): # indexing range fix
1415
a, b, op = int(numbers[i-1]), int(numbers[i]), operators[i-1]
1516
# correct the ops
@@ -34,7 +35,7 @@
3435
print("Invalid operators")
3536
break
3637

37-
numbers[i] = c
38+
numbers[i] = str(c)
3839
if not flag:
3940
continue
4041
print(f"Output:", numbers[-1])
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
choice = 'y'
2+
3+
while (choice =='y' or choice == 'Y') :
4+
try:
5+
exp = input("Enter the expression to be evaluated: ")
6+
print("Output:", eval(exp))
7+
except Exception:
8+
print(f"Invalid Input, try again") # print exception
9+
finally:
10+
choice = input("Do you want to continue? [y/n] : ") # always ask before ending
11+
12+
# can you make the code shorter and with improved answer?
13+
# like handling any basic arithmetic equation (that may have brackets too) ?
14+
# u might wanna find a special function in python

0 commit comments

Comments
 (0)