Python Forum

Full Version: Issue with if statement
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.

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.
You have to init y in the first sample:
y = 0
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