Home > Enterprise >  How to add a sentence before the the number/int PYTHON
How to add a sentence before the the number/int PYTHON

Time:10-20

Here's the code i did:

list = input("Enter the number: ")

p = print("Trailing zeroes = ")

print(p, list.count("0"))

Output:

Enter the number: 10000

Trailing zeroes = 

None 4

The output i wanted:

Enter the number: 10000

Trailing zeroes = 4

CodePudding user response:

Here is a working example of the code:

i = input("Enter the number: ")

p = "Trailing zeroes = "   str(list.count("0"))

print(p)

Output:

Enter the number: 1000
Trailing zeroes = 3

CodePudding user response:

With

list = input("Enter the number: ")

p = print("Trailing zeroes = ")

print(p, list.count("0"))

What you do is p = print("Trailing zeroes = ") which is not a value.

either you should have

list = input("Enter the number: ")

p = "Trailing zeroes = "

print(p, list.count("0"))

or

list = input("Enter the number: ")

print("Trailing zeroes = ",list.count("0"))

CodePudding user response:

Another way to do this.

list = input("Enter the number: ")

print("Trailing zeroes = ", list.count("0"))
  • Related