#Conner Kahn
#11/12
#I combined all of my skills
# [ ] import https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/rainbow as rainbow.txt
!curl https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/rainbow -o rainbow.txt
# [ ]  Open rainbow.txt in read mode & read as list with .readlines()
rainbowfile = open("rainbow.txt", 'r')
rainbowlines = rainbowfile.readlines()
# [ ] sort rainbow_colors list, iterate the list to print each color
rainbowlines.sort()
for line in rainbowlines:
    print(line)
# [ ] The Weather: import world_mean_team.csv as mean_temp.txt
!curl https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/world_temp_mean.csv -o mean_temp.txt
# [ ] The Weather: open file, read/print first line, convert line to list (splitting on comma)
weatherfile = open('mean_temp.txt', 'r')
headings = weatherfile.readline()
headings = headings.split(',')
print(headings)
# [ ] The Weather: use while loop to print city and highest monthly average temp in celsius
city_temp = weatherfile.readlines()
for line in city_temp:
    line = line.split(",")
    print(line[0], line[2])
# [ ] use curl to download https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/digits_of_pi as pi.txt
!curl https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/digits_of_pi -o pi.txt
# [ ] Set up the project files and initial values
pifile = open('pi.txt', 'r')
name = input('what is your name?')
print("Hi", name)
seed = len(name) 
pifile.seek(seed,0)
digit = pifile.seek(seed,0)
while True:
    guess = input("Guess the number?")
    if int(guess) == digit:
        print("congratulations")
        break
    else:
        print("incorrect")
pifile = open('pi.txt', 'r')
name = input('what is your name?')
print("Hi", name)
seed = len(name) 
pifile.seek(seed,0)
digit = pifile.seek(seed,0)
correct = 0
incorrect = 0
while True:
    while True:
        guess = input("Guess the number?")
        if guess.isdigit():
            guess = int(guess)
            break
        else:
            print("sorry that isnt a number, try again")
        
    if digit == '.':
        digit = pifile.seek(seed+1,0)
    elif digit == "\n":
        digit = pifile.seek(seed+1,0)
    elif guess == digit:
        print("congratulations")
        correct += 1
        break
    elif guess != digit:
        print("Incorrect")
        incorrect =+ 1
print("Correct:", correct, "incorrect:", incorrect)