0

What am I doing wrong?

I am trying to make a calculator on python, and if I use the '+' symbol, everything executes perfectly. If I dont, it comes up with the error shown below, although according to my code it should say "Try again." Error: Traceback (most recent call last): File "...\Playground\", line 4, in <module> if a.index ("+") ValueError: substring not found https://code.sololearn.com/c0yoGqbZ5fKx/?ref=app

10th Apr 2018, 2:31 PM
Robyn
3 Answers
+ 2
use this condition if "+" in a:
10th Apr 2018, 2:45 PM
michal
+ 2
From the documentation on str() .index() method. str.index(sub[,Ā start[,Ā end]])Ā¶ LikeĀ find(), but raiseĀ ValueErrorĀ when the substring is not found. It will raise a ValueError when the substring isn't found. You need to handle this.
10th Apr 2018, 2:46 PM
ChaoticDawg
ChaoticDawg - avatar
0
сŠ°Š¼ тŠ°ŠŗŠ¾Š¹
10th Apr 2018, 2:36 PM
Š•Š³Š¾Ń€