Python Forum
Issue with if statement - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Issue with if statement (/thread-5969.html)



Issue with if statement - trixter6673 - Oct-30-2017

hi there guys, I am new with python and need help with this issue as I can't seem to find any answer when I run the code. The code I used is :-
x= int(input("Enter a number: "))
if x == 1:
y += 1
print("y")

Additionally is this code correct below.
from math import*
x = int(input("Enter a number: "))
y = 5
if x ** sqrt(2) :
y = y + x
print(y)
I know you guys must be like ask teacher but I did he said to check the materials or online. How am I gonna learn when you can't help me with the mistake I create and also help me understand it.




RE: Issue with if statement - sparkz_alot - Oct-31-2017

After posting your code correctly, you need to say what the issue is that you are having. For example, what output are you expecting versus the output you are getting. If you are getting errors, post the error code in it's entirety between the 'error' tags.


RE: Issue with if statement - heiner55 - Oct-31-2017

You have to init y in the first sample:
y = 0


RE: Issue with if statement - trixter6673 - Nov-01-2017

hi sparz_alot sorry for not being clear and also thank you for telling me how to state my issue correctly and its ok now I finally got the code correctly. So the first code issue was syntax error basically issue with the structure of the code but now I fixed the issue also I identified what output I needed(which I didn't thought about it). I will this in my head when I ask for any help and also through looking for output I fixed my issue. Thanks you guys. U R GGGGGGSSS