# Go over each character of input
#      If that single character is NOT 
#       a valid digit of that base, 
#       return False immediately
# If you finish going through ALL the characters, 
#   then return True

def is_base_x (num_string, base):
    # YOUR CODE STARTS HERE







    # YOUR CODE ENDS HERE


# This will involve looping through each 
# character in num_string, converting it
# to its integer equivalent, multiplying
# it by the base raised to the current 
# exponent, and adding it to a running sum

def base_x_value (num_string, base):
    # YOUR CODE STARTS HERE







    # YOUR CODE ENDS HERE


"""
    Read the following code so that you understand 
    what it is doing.  However, do not need to (and
    should not) make any changes to it.  
"""

base = int (input ("Specify your base (2-10): "))
print()

if not (2 <= base <= 10):
    print (base, "is not a valid base for this program.")
    print ("Setting base to a default of 10.")
    print()
    base = 10

num_string = input ("Enter a valid base-" + str(base) + " number up to 8 digits long: ")
num_string = num_string[0:8] # In case user goes over 8 digits
print()

if is_base_x (num_string, base):
    print ("You entered:", num_string)
    print ("The base-10 value of", num_string, "is", base_x_value(num_string, base))
else:
    print (num_string, "is not a valid", "base-" + str(base), "number!")
    print ("Please re-run the program and try again...")

The program will prompt the user for some input -- specfically, a base (2-10) and an 8-digit number expressed in that base. If the number is a valid number in that base, the program will calculate its base-10 equivalent. Otherwise, it will print an error message. You will need to do the following things:
  1. Write a method to verify whether or not the user's input string is a valid number in the specified base.
  2. Write a method to calculate the value of the user's input string, in base-10.
Note that because of user input, the output will look different each time you run the program. When running the program, you can use this site to check the correctness of your program's solution.

Program output examples:

Example #1

Specify your base (2-10): 2

Enter a valid base-2 number up to 8 digits long: 10111010

You entered: 10111010
The base-10 value of 10111010 is 186

Example #2

Specify your base (2-10): 7

Enter a valid base-7 number up to 8 digits long: 20132601

You entered: 20132601
The base-10 value of 20132601 is 1672077

Example #3

Specify your base (2-10): 4

Enter a valid base-4 number up to 8 digits long: 10140013

10140013 is not a valid base-4 number!
Please re-run the program and try again...
        
Question: How did the process of editing this program go for you? What were your main challenges and how did you overcome them? What did you learn that may be of use as you move along in this class?