Answer to Question #101645 in Python for Brenda

Question #101645
Write a program that asks the user to input a word or phrase and then outputs the following information about that phrase:

All numbers if the input is all numbers.
Does not contain numbers if the input does not contain any numbers.
Contains a {digit} for each number in the phrase.
1
Expert's answer
2020-01-24T05:39:04-0500

word = input('Write word or a phrase: ')

try:

word = int(word)

print(word)

except ValueError:

checker = []

for i in word:

if i.isdigit():

print('Contains a: {' + i + '}')

checker.append(i)

if len(checker) == 0:

print('Does not contain numbers')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS