Python Forum
how do I make a number only print once but the number keeps on decreasing?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how do I make a number only print once but the number keeps on decreasing?
#5
import time
import winsound
 
# User Input
def choose():                            # With a function you have to return your multi var
    user = 'yes'
    plan = input("What Your Plan For Today? : ").lower()
    times = int(input("What Number? : "))
    while True:                   
        choose1 = input("Minute?Second?Hour? : ").lower()
        if 'hour' in choose1:
            multi = times * 3600
            break                 # You dont have to break just use return because you work with function
        elif 'minute' in choose1:
            multi = times * 60
            break                 # You dont have to break just use return because you work with function
        elif 'second' in choose1:
            multi = times
            break                 # You dont have to break just use return because you work with function
        else:
            print("Sorry Sir, There Is No Such Option")
 
# Looping     
while multi > 0 or user == 'yes':         # multi is not defined at this point so this will fail.
    print(multi)                          # you can put this line to linenumber #34
    time.sleep(1)
    multi -= 1                            # multi is not defined so this will fail.
    if multi == 0:
        print("Sir Its Time For You To Do Your Work And Have Nice Day! :)")        
        winsound.PlaySound('C:\\Users\\user\\Documents\\All About Python3 Or Programming\\All 
        Project With Python 3\\background.wav', winsound.SND_FILENAME)
        user = input("Do You Want To Make More Plans? : ").lower() 
        if user == 'yes':
            choose()
        else:
            user = 'no'
I hope this quick change works for you. I`ll didnt test this one.
import time
import winsound

# User Input
def choose():
    user = 'yes'
    plan = input("What Your Plan For Today? : ").lower()
    times = int(input("What Number? : "))
    while True:
        choose1 = input("Minute?Second?Hour? : ").lower()
        if 'hour' in choose1:
            return times * 3600
        elif 'minute' in choose1:
            return times * 60
        elif 'second' in choose1:
            return times
        else:
            print("Sorry Sir, There Is No Such Option")


# Looping
multi = 0
while True:
    time.sleep(1)
    if multi == 0:
        print("Sir Its Time For You To Do Your Work And Have Nice Day! :)")
        winsound.PlaySound('C:\\Users\\user\\Documents\\All About Python3 Or Programming\\All
        Project With Python 3\\background.wav', winsound.SND_FILENAME)
        user = input("Do You Want To Make More Plans? : ").lower()
        if user == 'yes':
            multi = choose()
            print(multi)
        else:
            user = 'no'
            # exit()
    else:
        if isinstance(multi, int):
            multi -= 1
Reply


Messages In This Thread
RE: how do I make a number only print once but the number keeps on decreasing? - by Killertjuh - Jan-03-2020, 09:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [redistribution] Reduce number + size of dependencies? Winfried 2 632 Jan-31-2025, 10:17 PM
Last Post: snippsat
  Syntax for Doubling a number ksp_802 3 617 Jan-12-2025, 07:04 PM
Last Post: ksp_802
  Printing the code line number arbiel 6 1,602 Jun-30-2024, 08:01 AM
Last Post: arbiel
  Finding the price based on industry and number of transactions chandramouliarun 1 1,679 Jun-04-2024, 06:57 PM
Last Post: marythodge4
Music Python Script Repeating Number When Saving Facebook Photos ThuanyPK 2 1,017 May-13-2024, 10:59 PM
Last Post: ebn852_pan
  intering int number akbarza 1 960 Apr-28-2024, 08:55 AM
Last Post: Gribouillis
Brick Number stored as text with openpyxl CAD79 2 4,704 Apr-17-2024, 10:17 AM
Last Post: CAD79
  [SOLVED] Pad strings to always get three-digit number? Winfried 2 1,239 Jan-27-2024, 05:23 PM
Last Post: Winfried
  Prime number detector Mark17 5 2,222 Nov-27-2023, 12:53 PM
Last Post: deanhystad
  Create X Number of Variables and Assign Data RockBlok 8 3,822 Nov-14-2023, 08:46 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020