0

i'm new on programming and began to code a calculator. i code it, and when i run it i'm taking error. actually, there's no error but when i run it, i can make calculations with only "add"

i think, i had wrongs on the 10th line. what should i do there?

as i say on title, i can't use this. please have a look at the 10th line.

and if you want to, you can edit the rest of the code.

thanks for help :)

while True:
    ilkSayi = int(input("ilk sayıyı giriniz..:"))
    while True:
        print("Toplama(+) için |1|")
        print("çıkarma(-) için |2|") 
        print("çarpma için(*) |3|")
        print("bölme için(/) |4|")
        print("üs almak için(**) |5|")
        islem = input("Yapmak istediğiniz işlem nedir..:")
        if islem != "1" and "2" "3" and "4" and "5": # 10th line
            print("Bir işlem yapabilmem için yukarıda belirtilen işlem sembollerini giriniz.")
        else:
            break
    ikinciSayi = int(input("ikinci sayıyı giriniz..:"))
    if islem== "1":
        print(f"sonuç..: {ilkSayi+ikinciSayi}")

    elif islem== "2" :
        print(f"sonuç..: {ilkSayi-ikinciSayi}")

    elif islem== "3" :
        print(f"sonuç..: {ilkSayi*ikinciSayi}")

    elif islem=="4":
        print(f"sonuç..: {ilkSayi/ikinciSayi}")

    elif islem=="5":
        print(f"sonuç..: {ilkSayi**ikinciSayi}")
        print("burada girdiğiniz ilk sayı taban, ikinci sayı üst alınmıştır.")

1 Answers1

1

You need to change if statement to:

if islem not in ("1", "2", "3", "4", "5"):

You may use and with if statement but each time you use it, you need to give a valid condition. For example,

if some_condition == "1" and other_condition != "2":

will perfectly work.

Deniz Kaplan
  • 1,549
  • 1
  • 13
  • 18