# CSIS 1595, Lab 3: Madlibs
# Due: Nov 1st 5:10pm
# Requirements:
# 1). Use at least one Proper Noun
# 2). Use at least ten blanks (with correct parts of speech given)
# 3). Users will be repeatedly prompted for the correct part of speech,
#     in the correct order
# 4). Write the completed story to the console output
# 5). Prompt the user to replay (y/n input)
# name your file <bannerID>_lab3.py and send it as an *email attachment*
# e.g., jwdittrich_lab3.py
# To: james.dittrich+YSU@gmail.com
# NOTE: file sharing links (OneDrive, Google Drive, DropBox) will NOT be
# followed or downloaded for time and security reasons.

# MADLIBS PSEUDOCODE

# replay loop (the game state)
#       declare story string
#       word input loop
#               prompt for user input
#       fix capitalization
#       replace placeholders
#       print output
#       prompt to replay(y/n)




# SOME EXAMPLES - A QUICK HOWTO:
story = "The NOUN_1 ran away with the NOUN_2"
story.replace('NOUN_1','sock')
# 'The sock ran away with the NOUN_2'

# notice the original string is unchanged:
# story
# 'The NOUN_1 ran away with the NOUN_2'

# overwrite the original string:
story = story.replace('NOUN_1','sock').replace('NOUN_2','shoe')
# story
# 'The sock ran away with the shoe'

# How to store the responses in a list:
responses = []
responses += [input("enter a noun: ").lower()]
# enter a noun: tree
# responses
# ['tree']
responses += [input("enter a verb: ").lower()]
# enter a verb: swam
# responses
# ['tree', 'swam']

# now use the list contents in the replace operation:
story = "The NOUN_1 VERB_1 away with the spoon"
story = story.replace('NOUN_1',responses[0])
# story
# 'The tree VERB_1 away with the spoon'
story = story.replace('VERB_1',responses[1])
# story
# 'The tree swam away with the spoon'

# Don't forget to assign the new string you replaced back to the variable!
# An example of what goes wrong:
story = "The NOUN_1 VERB_1 away with the spoon"
story.replace('NOUN_1',responses[0])
# 'The tree VERB_1 away with the spoon'
story.replace('VERB_1',responses[1])
# 'The NOUN_1 swam away with the spoon'

# split produces at least a single element list
"John".split()
# ['John']

len("John".split())
# 1

response = []
response += ["John"]
# response[0]
# 'John'

response = []
response += ["John Jacob Jingleheimer Schmidt"]
# response[0]
# 'John Jacob Jingleheimer Schmidt'

# How to split proper nouns into lists of lists: 
response[0] = response[0].split()
# response
# [['John', 'Jacob', 'Jingleheimer', 'Schmidt']]
# response[0]
# ['John', 'Jacob', 'Jingleheimer', 'Schmidt']

# Let's assume the input is lowercase and we need to fix it:
response = []
response += ["john jacob jingleheimer schmidt"]
# response[0]
# 'john jacob jingleheimer schmidt'
response[0] = response[0].split()
# response
# [['john', 'jacob', 'jingleheimer', 'schmidt']]
# response[0]
# ['john', 'jacob', 'jingleheimer', 'schmidt']
# response[0][1]
# 'jacob'
# response[0][0]
# 'john'

# How to use list iteration to fix each item:
count = 0
while(count < len(response[0])):
	response[0][count] = response[0][count].capitalize()
	count += 1

# response
# [['John', 'Jacob', 'Jingleheimer', 'Schmidt']]
# response[0]
# ['John', 'Jacob', 'Jingleheimer', 'Schmidt']

# How to print to all one line:
count = 0
while(count < len(response[0])):
	print(response[0][count], end=' ')
	count+=1
# John Jacob Jingleheimer Schmidt 


# Here's another way, using String concatenation:
count = 0
fn = ''
while(count < len(response[0])):
	fn += response[0][count] + ' '
	count+=1
else:
	fn = fn.strip()
	
# fn
# 'John Jacob Jingleheimer Schmidt'
