Ask coding questions

← Back to all posts
If command on Python
KierstenKuk (20)

Can someone give me a template for the "If=" Command please?

Answered by Coder100 (17091) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (17091)

try:

a = input("say hello: ")

if a == "hello":
  print("gj")
else:
  print("try again with a brain")
AloegelhiPlaysR (109)

Here's awesome things you can compare using if statements!

If you're comparing a STRING (something surronded in ' ')
This will help:

if 'whatever_string_here' == 'whatever_string_here':
   print('Verified!')

For numbers you can do something like this:

if NUMBER_VALUE > NUMBER_VALUE:
   # Code Here
JacobMcPherson1 (196)

example

if 1 == 1:
  print("1 is equal to 1")
JacobMcPherson1 (196)

@KierstenKuk np, also click the check mark next to my comment

KierstenKuk (20)

@JacobMcPherson1 for the code you gave me, I'm trying to replace the 1 == 1 with something else. How do I make the code work?

JacobMcPherson1 (196)

@KierstenKuk What are you trying to replace it with?

JacobMcPherson1 (196)

@KierstenKuk do you want to check user input?

KierstenKuk (20)

@JacobMcPherson1 what are cycles? it says "Will be awarded 5 cycles"