4️⃣

7.4 Practice

Practice

Upper

Continuously ask a user to enter words. (Make sure that the input given is actually just 1 word.) Store the words in a list. Stop asking the user for words if they enter an empty string (the string has no characters or is completely whitespace). Convert all of the words in the list into uppercase. Print the resulting list. (If the user quits right away, print an empty list.)

Vowels

Create a program that takes a string from the user and prints the number of vowels that are in the string.

Ingly

Write a Python program to add "ing" at the end of a given string (length of the string should be at least 3).

If the given string already ends with "ing", add "ly" instead

If the string length of the given string is less than 3, leave it unchanged.

Print the resulting string

Note: adapted from W3Resource, problem 6

Replace

Write a Python program to print a string from a given string where all occurrences of its first char have been changed to "$" except the first char itself.

Sample String: 'restart'

Expected Result: 'resta$t'

First Three Words

Write a program that asks the user to enter a sentence. Print the first three words in the sentence. (Assume the user enters at least 3 words.)

Previous Section

Next Section

⚖️

Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.