Jun-16-2018, 06:18 PM
Hello,
I am having trouble assigning a string value (namely, "Odd" or "Even") to val in my conditional operator. I am to have a user input a number, use a conditional operator to determine whether the number is odd or even, assign "Odd" or "Even" to a variable, and then print the result using that assigned variable.
Thanks in advance for your help!
I am having trouble assigning a string value (namely, "Odd" or "Even") to val in my conditional operator. I am to have a user input a number, use a conditional operator to determine whether the number is odd or even, assign "Odd" or "Even" to a variable, and then print the result using that assigned variable.
Thanks in advance for your help!
num = int(input("Enter a whole number; this program will determine if your value is odd or even!\n")) val = "Even" if (num % 2 == 0) else val = "Odd" print("The number you input is", val)