<jupyter_start><jupyter_text>Input ValidationInput validation code verifies that user supplied data, such as text from the input() function, is formatted appropriately.* try/except* isdigit()* pyinputplus try/except<jupyter_code>while True:
  try:
    ticker = str(input("Please type in a ticker symbol "))
    break
  except AttributeError:
    print('Please enter proper Ticker Symbol')
print('Your age is: ' + str(ticker))
#Reference: http://www.easypythondocs.com/validation.html
def get_interger(prompt):

  valid_input=False
  while not valid_input:
    try:
      number = int(input(prompt))
      #break
      valid_input = True
    except ValueError:
      print('Please enter a whole number')
  return number
#Reference: http://www.easypythondocs.com/validation.html
age = get_interger("How old are you???")
print('Your age is: ' + str(age))<jupyter_output>How old are you???tewnty
Please enter a whole number
How old are you???20
Your age is: 20<jupyter_text>isdigit()<jupyter_code>#Reference: http://www.easypythondocs.com/validation.html
def get_int_isdigit(prompt):
  valid_input=False
  while not valid_input:
    age_1 = input(prompt)
    if age_1.isdigit():
      age_1 = int(age_1)
      #break
      valid_input=True
    else:
      print('You must enter a valid number')
  return age_1

age_2 = get_int_isdigit('How old are you??')
print('You are ' + str(age_2))<jupyter_output>How old are you??twenty
You must enter a valid number
How old are you??20
You are 20<jupyter_text>Module: pyinputs<jupyter_code>pip install pyinputplus
import pyinputplus as pyipp
age_input= pyipp.inputNum("How old are you??")
print('Your age :' + str(age_input))
# two inputs
number = 1
another = 1

#many lines of code
try:
  number/another
  #more line of code!!
  with open('readme.txt') as f:
    f.readlines()
except ZeroDivisionError:
  print("we cannot divide number by zero...")
except FileNotFoundError:
  print("Couldn't find a file")

#here may have more lines of code
print("Finally After Handling Many Errors")
'''def build_url():
  ticker = input("Please type in a ticker symbol ")
  url_pattern = 'https://au.finance.yahoo.com/quote/{}/profile?p={}'
  result = url_pattern.format(ticker, ticker)
  return result'''
def build_url():
  while True:
    try:
      ticker = str(input("Please type in a ticker symbol "))
      break
    except AttributeError:
      print('Please enter proper Ticker Symbol')
  url_pattern = 'https://au.finance.yahoo.com/quote/{}/profile?p={}'
  result = url_pattern.format(ticker, ticker)
  return result
build_url()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11544401544401545, 'fraction_numerical': 0.006563706563706564, 'mean_word_length': 4.420502092050209, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '485329', 'license': 'MIT', 'n_tokens_mistral': 885, 'n_tokens_neox': 852, 'n_words': 249, 'path': 'input_validation.ipynb', 'repo_name': 'Parshav-Shah/ISYS5002_portfolio', 'size': '2590'}