Question

Using Python, write a program that keeps asking the user for text until they type "exit"

To Exit Or Not Write a program that keeps asking the user for text until they type exit Console 1 Enter number 1 3 Enter number 5 5 Enter number 7 Enter number 8 1 9 Enter number 10 9 11 Enter number 12 3 13 Enter number 14 4 15 Enter number 16 exit 17 Bye! 18

0 0
Add a comment Improve this question Transcribed image text
Answer #1


Given below is the code (tested on python 3.5) for the question.
Make sure to indent the code exactly as shown in image. INDENTATION IS LOST WHEN CODE IS UPLOADED ON CHEGG SITE
Please don't forget to rate the answer if it was helpful. Thank you

1 done# False 2 while not done: 3 str-input(Enter a number: 1n done True 7 print(Bye!)


done = False
while not done:
str = input('Enter a number: ')
if str == 'exit':
done = True

print('Bye!')


output
-----
Enter a number:
1
Enter a number:
5
Enter a number:
8
Enter a number:
1
Enter a number:
9
Enter a number:
3
Enter a number:
4
Enter a number:
exit
Bye!

Add a comment
Know the answer?
Add Answer to:
Using Python, write a program that keeps asking the user for text until they type "exit"...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Build a list by asking the user to enter names until the user enters "done". #...

    Build a list by asking the user to enter names until the user enters "done". # Build a list which contains all numbers divisible by 3 between (exclusive) and 100 (exclusive) Write a Python program that builds a list consisting of positive even numbers less than 150 (exclusive) Write a Python program that builds a list of numbers between -10 (inclusive) to 10 (inclusive) without the number @ 5 Calculations using lists

  • solve using the code provided Write a program that will continuously read words from the user,...

    solve using the code provided Write a program that will continuously read words from the user, word by word till the user enter "quit”, the program should print each word in reverse order. Sample Session: (User input in Red color) Enter a word: hello olleh Enter a word: Ahmad damhA Enter a word: quit Good Bye 9 dinclude <iostream> 10 dinclude <cstring> 11 using namespace std; 12 13 int main() { 14 15 char word(100); 16 cin>>word; 17 while (strcmp(word,...

  • Write a PYTHON program that allows the user to navigate the lines of text in a...

    Write a PYTHON program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the...

  • Write a Python program that keeps reading in names from the user, until the user enters...

    Write a Python program that keeps reading in names from the user, until the user enters 0. Once the user enters 0, you should print out all the information that was entered by the user. Use this case to test your program: Input: John Marcel Daisy Samantha Nelson Deborah 0 ================ Output: John Marcel Daisy 25 Samantha Nelson Deborah Hints: Create an array Names to hold the input names. Use the Names.append(x) function to add a new name to the...

  • Write a text analyzer program using Python. The program should prompt the user for text to...

    Write a text analyzer program using Python. The program should prompt the user for text to analyze using the following prompt: Please enter text to analyze or press ENTER (without text) to exit: If the following text is input into by the user: Fog everywhere. Fog up the river, where it flows among green aits and meadows; fog down the river, where it rolls deified among the tiers of shipping and the waterside pollutions of a great (and dirty) city....

  • Write python program using IDLE Write a full program that asks the user to enter his/her...

    Write python program using IDLE Write a full program that asks the user to enter his/her name then repeatedly ask to enter the temperature in Fahrenheit and convert it to Celsius, the program should then prompt the user if he/she wants to continue or exit the program. The formula for the conversion is: °C = (°F - 32) x 5/9 The program should use a function for the conversion. An Example of a sample run should appear on the screen...

  • PLEASE complete each task in python Write a console program that prompts the user for the...

    PLEASE complete each task in python Write a console program that prompts the user for the desired sum, then repeatedly rolls two six-sided dice (using a Random or RandomGenerator object to generate random numbers from 1-6) until the sum of the two dice values is the desired sum. Here is the expected dialogue with the user: Desired sum: 9 4 and 3 = 7 3 and 5 = 8 5 and 6 = 1 1 5 and 6 = 11...

  • write in python idle Write a full python program that asks the user to type in...

    write in python idle Write a full python program that asks the user to type in 10 words using a loop, prompting the user for each word with a number. The program then displays the longest word and the shortest word the user typed in.

  • In Python, write a function numLetters() that keeps prompting the user for words until they hit...

    In Python, write a function numLetters() that keeps prompting the user for words until they hit return (using while loops). The function should then return the percent of 3-letter words that were entered. So, if a user entered ten words and 4 of the words had 3 letters, then the percent of 3-letter words is 40

  • Write a full python program that asks the user to type in 10 words using a...

    Write a full python program that asks the user to type in 10 words using a loop, prompting the user for each word with a number. The program then displays the longest word and the shortest word the user typed in.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT