0

i want to make a converter for SGD to USD but im stuck at if statement . it just didnt recognize the input(). im learning so my code might be really stupid, sorry in advance aite.

def converter(scal):

    return scal * 1.33504


print('Welcome to Smurk Converter ')
print('Press 1 to convert SGD to USD :')
choice = input()

if choice == 1:
    print('Amount of money you want to convert: $')
    amount = input()
    his_amount = amount
    print(amount)
    print('If you were to convert that amount SGD to USD...')
    print('It will be: $')
    print(converter(his_amount))

else:
    print('Wrong Input, just enter either 1 or 2')

Please help, thanks.

  • it says this when i execute and pressed 1 , Welcome to Smurk Converter Press 1 to convert SGD to USD : 1 Wrong Input, just enter either 1 or 2 – Minz Coder May 11 '18 at 16:02
  • even when i press 1.. it goes to else which it print Wrong iinput – Minz Coder May 11 '18 at 16:03
  • `input()` returns a string, so you have the string value `'1'`, not the integer value `1`. Convert your string to an integer first, *or* compare to strings. – Martijn Pieters May 11 '18 at 16:04

1 Answers1

2

If you use input, it will always be a string, so what you need to change is the following code

choice = input()

to

choice = int(input())

Also, one more line of code you need to change is the following

amount = input()

to

amount = float(input())
rawwar
  • 4,834
  • 9
  • 32
  • 57