Ask coding questions

← Back to all posts
PythonCoder100 (5)

In HTML, how do you add an interactive text box?

Answered by timmy_i_chen (1117) [earned 5 cycles]
View Answer
timmy_i_chen (1117)

If you want it to appear on the screen (like an input box where users can type), you can use <input />

If you want a pop up for the user, you can use prompt() in javascript

PythonCoder100 (5)

@timmy_i_chen ok thanks! how do you add an "if" statement in python 2.7?

timmy_i_chen (1117)

@PythonCoder100 I think it's the same as python3, something like:

if condition:
  # execute this
PythonCoder100 (5)

@timmy_i_chen ok thanks, and I tried to do a "else" command, but it would not work. Here is the code.

print ("Hello! This is a Fortnite game. You have to choose what to do in certain situations.")
print("Alright. Lets get started.")
var1= raw_input ("What is your name?")
print ("Ok. Hi "+ var1)
var2= raw_input ("Where will you land? Paradise Palms, Fatal Fields, Risky Reels, or Flush Factory? ")
print ("Ok. You landed at"+ var2)
ok= raw_input ("You found a blue tactical shotgun. The problem is, there is a Skull Trooper in front of you trying to get the same gun. Will you run away or go for the gun?")
if "ok"== "go for the gun":
print ("Your common sense overruled your choice. You ran away.")
print ("You ran away. Good choice.")

timmy_i_chen (1117)

@PythonCoder100 Should share it with us in a repl - otherwise it is hard to read the code!

CBlockSurprise (17)

@PythonCoder100 You need a ':' after the else


if condition:
else: #<--

PythonCoder100 (5)

I want to ask the reader a question, but i dont know how