Input

Ask the user for their input and place into Var1

Var1 = raw_input("What variable do you want to set the variable to?"

Verify that the input is not empty

original = raw_input("Enter a word: ")
if len(original) > 0:
  print(original)
else:
  print "empty"

Verify that the input is not empty and ONLY alphabetical characters

original = raw_input("Enter a word: ")
if len(original) > 0 and original.isalpha():
  print(original)
else:
  print "empty"

Define an integer as input

number = int(raw_input("What is your favorite number?"))

Define a float as input

number = float(raw_input("What is your favorite double?"))

 

Leave a Reply

Your email address will not be published. Required fields are marked *