+ 1
Set word as a value if user input is x (python3. 7)
I want to set a value like x = 0.25 if user input for exmple is '2' what can i do?
5 odpowiedzi
+ 6
if you write "if" in lowercase your code does work as expected. Also put print() in indentation as shown:
a1 = float(input("what is first mark?"))
if a1 == 2:
p1 = '0.25'
print(p1)
+ 3
you can try this:
inp = input('Input:')
if inp == '2':
x = 0.25
+ 1
For exmple it would like to be something like this :
a1 = float(input("what is first mark?"))
If a1 == 2:
p1 = '0.25'
print(p1)
+ 1
I tried but it dosent work, just like my own code it says the 'x' is not defined 🤷♂️
+ 1
Thank you very much, it was very helpful🤩