Python Forum
Sentinel Controlled Loop - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Sentinel Controlled Loop (/thread-16721.html)



Sentinel Controlled Loop - adrury2 - Mar-11-2019

Hello Everyone,
My Professor wants us to create code using a list of at least 8 characters and by manipulating a Sentinel Controlled Loop. He wants our code to sort the list to display IncreasingLength, DecreasingLength, TheMostVowels, TheLeastVowels, CapitalizeEveryOtherCharacter, ReverseWordOrdering, and FoldWordsOnMiddleOfList. I have can't seem to get a hold of my professor so I haven't been able to figure out how to even start on putting this code together. Please help me. Thanks guys!


RE: Sentinel Controlled Loop - Yoriz - Mar-11-2019

Start by writing some pseudo code of the steps it would take for you to carry out each tasks.


RE: Sentinel Controlled Loop - perfringo - Mar-12-2019

I feel that assignment needs to described more precisely.

"create code using a list of at least 8 characters"

>>> lst = ['a', 'b', 'c', 'f', 'g', 'h', 'i', 'j']
"He wants our code to sort the list to display IncreasingLength, DecreasingLength, TheMostVowels, TheLeastVowels, CapitalizeEveryOtherCharacter, ReverseWordOrdering, and FoldWordsOnMiddleOfList"

I can't see how it is useful to manipulate characters this way. Maybe it's list of words where word length is at least 8 characters?


RE: Sentinel Controlled Loop - adrury2 - Mar-12-2019

def main():
# declare any necessary variable(s)


# // Loop: while the user wants to continue processing more lists of words
#
# // Loop: while the user want to enter more words (minimum of 8)
# // Prompt for, input and store a word (string) into a list
# // Pass the list of words to following functions, and perform the manipulations

# // to produce and return a new, modified, copy of the list.
# // NOTE: None of the following functions can change the list parameter it
# // receives – the manipulated items must be returned as a new list.
#
# // SortByIncreasingLength(…)
# // SortByDecreasingLength(…)
# // SortByTheMostVowels(…)
# // SortByTheLeastVowels(…)
# // CapitalizeEveryOtherCharacter(…)
# // ReverseWordOrdering(…)
# // FoldWordsOnMiddleOfList(…)
# // Display the contents of the modified lists of words
#
# // Ask if the user wants to process another list of words

This is the Psuedocode we were given to go off of. I can't seem to figure it out though. So far I've come up with
def main():
	ListofWords=[]
	numberofWords = 0
	
newWord = input("Enter next word, or 'Exit' to quit:")

	while newWord != "Exit":
		ListofWords.append(newWord)
		numberofWords = numberofWords+1	
	if numberofWords<8:
		print("There are not enough words")
	else:	
I have no idea where to go from here. Anyone have any ideas on how I'd go about writing this code?