Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 8 Weeks Ago, 4 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
I'm having trouble getting started with this (Python)
Â
Prompt the user for a string that contains two strings separated by a comma. (1 pt)
Ex:
Enter input string: Jill, Allen
Â
(2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts)Â
Â
Ex:
Enter input string: Jill Allen
Error: No comma in string.
Enter input string: Jill, Allen
Â
(3) Using string splitting, extract the two words from the input string and then remove any spaces. Output the two words. (2 pts)Â
Â
Ex:
Enter input string: Jill, Allen
First word: Jill
Second word: Allen
Â
(4) Using a loop, extend the program to handle multiple lines of input. Continue until the user enters q to quit. (2 pts)Â
Â
Ex:
Enter input string: Jill, Allen
First word: Jill
Second word: Allen
Enter input string: Golden , Monkey
First word: Golden
Second word: Monkey
Enter input string: Washington,DC
First word: Washington
Second word: DC
Enter input string: q
Ans-----------wer-----------: -----------Â ----------- wh-----------ile-----------(1)-----------: -----------Â Â----------- s -----------= r-----------aw_-----------inp-----------ut(-----------"En-----------ter----------- in-----------put----------- st-----------rin-----------g:"-----------) -----------Â Â----------- if----------- s -----------== -----------"q"----------- : ----------- Â -----------Â Â----------- Â -----------bre-----------ak ----------- Â -----------Â i-----------f s-----------.fi-----------nd(-----------','-----------)==------------1:----------- Â----------- Â -----------Â Â----------- pr-----------int----------- "E-----------rro-----------r: -----------No -----------com-----------ma