#06-1###################################################
"""Write a program that asks the user to enter a string.
The program should then print the following:
(a) The total number of characters in the string
(b) The string repeated 10 times
(c) The first character of the string (remember that string indices start at 0)
(d) The first three characters of the string
(e) The last three characters of the string
(f) The string backwards
(g) The seventh character of the string if the string is long enough and a message otherwise
(h) The string with its first and last characters removed
(i) The string in all caps
(j) The string with every a replaced with an e
(k) The string with every letter replaced by a space
"""

##enter_string = input("Enter Your full name: ")
##print("(a)" , len(enter_string))
##print("(b)", enter_string * 10)
##print("(c)", enter_string[:1])
##print("(d)",enter_string[:3])
##print("(e)", enter_string[-3:])
##print("(f)",enter_string[::-1])
##if len(enter_string) > 7:
##    print("(g)",enter_string[:7])
##else:
##    print("(g)","String not long enough")
##print("(h)", enter_string[1:-1])
##print("(i)",enter_string.upper())
##for  a in  range(len(enter_string)):
##    if enter_string[a] == 'a':
##        enter_string = enter_string.replace('a', "e")
##        print("(j)",enter_string)
##for  a in  range(len(enter_string)):
##    if enter_string.isalpha():
##        enter_string = enter_string.replace(enter_string, " ")
##        print("(k)",enter_string,end="")


#06-2####################################################
""""A simple way to estimate the number of words in a
string is to count the number of spaces in the string.
Write a program that asks the user for a string and
returns an estimate of how many words are in the string."""

##ctr = 0
##s1 = input("Enter a string of words: ")
##print("The number of words in the string is: ",s1.count(' ') + 1)
###or
##for  a in  range(len(s1)):
##    if s1[a] ==(" "):
##        ctr += 1
##print("The number of words in the string is: ",ctr+1)

#06-3######################################################
"""People often forget closing parentheses when entering
formulas. Write a program that asks the user to enter a
formula and prints out whether the formula has the same
number of opening and closing parentheses."""

##ctrL = 0
##ctrR = 0
##s1 = input("Enter a lengthy formula with parentheses: ")
##for  a in  range(len(s1)):
##    if s1[a] == ("("):
##        ctrL += 1
##    if s1[a] == (")"):
##        ctrR += 1
##print("ctrL =",ctrL)
##print("ctrR =",ctrR)
##if (ctrL == ctrR):
##    print("The parentheses match")
##else:
##    print("The parentheses do not match")


#06-4######################################################
"""Write a program that asks the user to enter a word and
prints out whether that word contains any vowels."""

### print(vowels[j], j)
##vowels =['a','e','i','o','u']
##count =0
##word =input("Enter Word: ")
##for i in range(len(word)):
##    for j in range(5):
##        if vowels[j] in word[i]:
##            count += 1
##if(count) > 0:
##    print("The word contains at least one vowel")
##else:
##    print("The word does not contain a vowel")


#06-5######################################################
"""Write a program that asks the user to enter a string.
The program should create a new string called new_string
from the user’s string such that the second character is
changed to an asterisk and three exclamation points are
attached to the end of the string. Finally, print
new_string. Typical output is shown below:

Enter your string: Qbert

Q*ert!!!"""

##string = input("Enter a string: ")
##s1 = string[0]+"*"+string [2:]
##print(s1 + "!!!")


#06-6######################################################

"""Write a program that asks the user to enter a string
s and then converts s to lowercase, removes all the
periods and commas from s, and prints the resulting
string."""


##input_string= input("Please enter a string: ")
##input_string = input_string.lower()
##input_string = input_string.replace('.','')
##input_string = input_string.replace(',','')
##print(input_string)
### Example This , is a beautiful , day.

#06-7######################################################
"""Write a program that asks the user to enter a word and
determines whether the word is a palindrome or not. A
palindrome is a word that reads the same backwards as
forwards."""

##user_word = input("Enter a Word: ")
###eg kayak
##if user_word == user_word[::-1]:
##    print(user_word," This is a palindrome")
##else:
##    print(user_word ," This is not a palindrome")


#06-8######################################################
"""At a certain school, student email addresses end with
@student.college.edu, while professor email addresses end
with @prof.college.edu. Write a program that first asks
the user how many email addresses they will be entering,
and then has the user enter those addresses. After all the
email addresses are entered, the program should print out
a message indicating either that all the addresses are
student addresses or that there were some professor
addresses entered."""


##num_of_email = int(input("Enter the number of emails: "))
##n = 0
##student_count = 0
##teacher_count = 0
##while n < num_of_email:
##    email = input("Enter Student or `Teacher Email: ")
##    if "prof" in email:
##        teacher_count += 1
##        n +=1
##    elif "student" in email:
##        student_count += 1
##        n +=1
##if teacher_count == num_of_email:
##    print("All emails were that of teachers")
##if student_count == num_of_email:
##        print("All emails were that of student")
##if  student_count != num_of_email and teacher_count != 0:
##       print("Email list contained both professors and student email")



#06-9######################################################
"""Ask the user for a number and then print the following,
where the pattern ends at the number that the user enters.
1
2
3
4"""


##user_num = int(input("Enter a number: "))
##n=0
##while  n< user_num:
##    n+=1
##    print(n)


#06-10######################################################
"""Write a program that asks the user to enter a string,
then prints out each letter of the string doubled and on a
separate line. For instance, if the user entered HEY, the
output would be
HH
EE
YY"""

##user_string = input("Enter a string: ")
##for letter in user_string:
##    print(letter * 2)


#06-11######################################################

"""Write a program that asks the user to enter a word that
contains the letter a. The program should then print the
following two lines: On the first line should be the part
of the string up to and including the first a, and on
the second line should be the rest of the string. Sample
output is shown below:

Enter a word: buffalo
buffa
lo"""

##s1 = input("Enter a string that contains the letter a: ")
##for i in range(len(s1)):
##    if s1[i] == "a":
##        print(s1[:+2])
##        print(s1[i+1:])
##        break



#06-12######################################################
"""Write a program that asks the user to enter a word and
then capitalizes every other letter of that word. So if the
user enters rhinoceros, the program should print
rHiNoCeRoS."""


##user_input = input("Enter word: ")
##result = ""
##for letters in range(len(user_input)):
##    if letters % 2 != 0:
##       result =  result + user_input[letters].upper()
##    else:
##        result = result + user_input[letters].lower()
##print(result)


#06-13######################################################    
"""Write a program that asks the user to enter two strings
of the same length. The program should then check to see if
the strings are of the same length. If they are not, the
program should print an appropriate message and exit. If
they are of the same length, the program should alternate
the characters of the two strings. For example, if the user
enters abcde and ABCDE the program should print out
AaBbCcDdEe."""

##s1 = input("Enter the first string: ")
##s2 = input("Enter the second string: ")
##result = ""
##if len(s1) != len(s2):
##    print("Both strings do not have the same length")
##    exit()
##else:
##    for i in range(len(s1)):
##         result =  result + s2[i] + s1[i]
##    print(result)
    

#06-14######################################################  
"""Write a program that asks the user to enter their name
in lowercase and then capitalizes the first letter of each
word of their name."""

##user_input = input("Enter yur full name in lower case :")
##print(user_input.title())


#06-15###################################################### 
"""When I was a kid, we used to play this game called Mad
Libs. The way it worked was a friend would ask me for some
words and then insert those words into a story at specific
places and read the story. The story would often turn out to
be pretty funny with the words I had given since I had no
idea what the story was about. The words were usually from a
specific category, like a place, an animal, etc.
For this problem you will write a Mad Libs program. First,
you should make up a story and leave out some words of the
story. Your program should ask the user to enter some words
and tell them what types of words to enter. Then print the
full story along with the inserted words. Here is a small
example, but you should use your own (longer) example:


Enter a college class: CALCULUS
Enter an adjective: HAPPY
Enter an activity: PLAY BASKETBALL
CALCULUS class was really HAPPY today. We learned how to
PLAY BASKETBALL today in class. I can't wait for tomorrow's
class!




"""

##name = input(" What is your name: ")
##country= input("Where are you from: ")
##dream= input("What is your dream? ")
##user_story = "Dear {name} , you are a great programmer. Always remember practice makes progress, you are from {country} a beautiful country, Believe in yourself and your will achieve your dream to be a {dream}".format(name=name,country=country,dream=dream)
##print(user_story)

 
#06-16######################################################
"""Companies often try to personalize their offers to make
them more attractive. One simple way to do this is just to
insert the person’s name at various places in the offer. Of
course, companies don’t manually type in every person’s
name; everything is computer-generated. Write a program
that asks the user for their name and then generates an
offer like the one below. For simplicity’s sake, you may
assume that the person’s first and last names are
one word each.
"""

##first_name = input("Please enter your first  name: ")
##last_name = input("Please enter your last name: ")
##message = f"Dear {first_name} {last_name} I am pleased to offer you our new Platinum " \
##          f"Plus Rewards card at a special introductory APR of 47.99%. {first_name}, an offer" \
##          f"like this does not come along every day, so I urge you to call now toll-free at 1-800-314-1592. We cannot " \
##          f"offer such a lowrate for long, {first_name}, so call right away.".format(first_name=first_name,last_name=last_name)
##print(message)

  
#06-17###################################################### 
"""
Write a program that generates the 26-line block of letters
partially shown below. Use a loop containing one or two print
statements.
abcdefghijklmnopqrstuvwxyz
bcdefghijklmnopqrstuvwxyza
cdefghijklmnopqrstuvwxyzab
...
yzabcdefghijklmnopqrstuvwx
zabcdefghijklmnopqrstuvwxy
"""

##alphabet="abcdefghijklmnopqrstuvwxyz"
##for m in range (26):
##    for j in range (26):
##        print(alphabet[(m+j)%26],end='')
##    print()

 
#06-18######################################################
"""

The goal of this exercise is to see if you can mimic the
behavior of the in operator and the count and index methods
using only variables, for loops, and if statements.

(a) Without using the in operator, write a program that asks
the user for a string and a letter and prints out whether or
not the letter appears in the string.

(b) Without using the count method, write a program that
asks the user for a string and a letter and counts how many
occurrences there are of the letter in the string.

(c) Without using the index method, write a program that
asks the user for a string and a letter and prints out the
index of the first occurrence of the letter in the string.
If the letter is not in the string, the program should say
so
"""

###a
##s1 = input("Enter a string: ")
##l1 = input("Enter a letter: ")
##i =0
##found= False
##while (i < len(s1)):
##    if s1[i] == l1:
##        found= True
##        break
##    else:
##        i+=1
##if found == True:
##    print("Letter was found")
##else:
##    print("Letter was not found")
    
###b
##s1 = input("Enter a string: ")
##l1 = input("Enter a letter: ")
##i = 0
##count = 0
##while i < len(s1):
##    if (s1[i] == l1):
##        i+=1
##        count +=1
##    else:
##        i += 1
##print(f"The letter occurs {count} times")


###c edit solution a to have answer to c
##s1 = input("Enter a string: ")
##l1 = input("Enter a letter: ")
##found = False
##i = 0
##count = 0
##while i < len(s1):
##    if (s1[i] == l1):
##        print("The index of",l1,"is",i)
##        found = True
##        break
##    else:
##        i += 1
##if(not found):
##    print("The letter was not found")
    

  
#06-19######################################################
"""Write a program that asks the user for a large integer
and inserts commas into it according to the standard
American convention for commas in large numbers. For
instance, if the user enters 1000000, the output should be
1,000,000"""

##ctr = 0
##workNum1 = ""
##num1 = input("Enter number: ")
##print('{:,}'.format(int(num1)))
###or
##for i in range(len(num1),0,-1):
##    workNum1+= str(i)
##    ctr +=1
##    if (ctr % 3 == 0): 
##        workNum1 += ","
##print(workNum1[::-1].strip(","))
