Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6737043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:12:06+00:00 2026-05-26T11:12:06+00:00

This is currently what I’m at, I’m stuck with how to find how many

  • 0

This is currently what I’m at, I’m stuck with how to find how many times the digit was in the number, using the for loop. If anyone has any basic ideas, I’m new to python, so I’m not too knowledgeable about this language.

#Assignment 6

#Start out with print instructions
print """
This program will take a Number and Digit that you enter.
It will then find the number of times the digit is in your number.
Afterwards, this program will multiply your number by your digit.
"""

#Get the user's number

number = raw_input("Enter a number: ")

#Use a while loop to make sure the number is valid

while (number == ""):
    print "You have entered an invalid number."
    number = raw_input("Enter another number: ")

#Get the digit

digit = raw_input("Enter a digit between 0-9: ")

#Use a while loop to make sure the digit is valid

while (int(digit) > 9):
    print "You have entered an invalid digit."
    digit = raw_input("Enter a digit between 0-9: ")

#Set the count to 0
count = 0

#Show the user their number and digit

print "Your number is:", number, "And your digit is:", digit

#Use the for loop to determine how many times the digit is in the number

for d in number:
    if d == digit
        count +=1
    else
        count +=0
print d, count
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:12:06+00:00Added an answer on May 26, 2026 at 11:12 am

    Your code is syntactically invalid in its current stage,

    if d == digit
        count +=1
    else
        count +=0
    

    is missing colons:

    if d == digit:
        count +=1
    else:
        count +=0 # or just pass, or better, skip the whole else tree
    

    Apart from that, it works, although you should catch the errors that occur when the first (or second) input is, say, a.

    You haven’t yet solved this sub-assignment:

    Afterwards, this program will multiply your number by your digit.

    The Python tutorial will be very helpful in finding out how to multiply numbers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure this is really easy but I can't find any info on it.
This doesn't seem like it should be difficult, but I'm stuck currently. I'm trying
I'd like to find any unused resources in my Android project - this includes
I'm using this currently: $(document).ready(function () { $('ul#nav > li').hover(function () { $('ul:first', this).show();
How to find the text description of what 'this' currently points to in javascript.
Whats the best way to find out what $(this) currently equals in jQuery? For
I am doing this currently, class Page { // variable to hold DBC class
I have something like this currently: <div class = className style = position: absolute;
this is currently my code byte[] bytes = { 0x42, 0x1c, 00, 00 };
This is currently my htacess file: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.