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

  • Home
  • SEARCH
  • 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 7825079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:49:44+00:00 2026-06-02T08:49:44+00:00

What I am trying to accomplish is first text appears after 1 second. then

  • 0

What I am trying to accomplish is first text appears after 1 second. then 2, ect. till 10. then when time equals 10, the time decreases, so the text appears after 9 seconds, then 8 etc.

How could I fix this code so that it works properly?

The error:

Traceback (most recent call last):
  File "C:/Users/Eric/Dropbox/time.py", line 13, in <module>
    time.sleep(time)
AttributeError: 'int' object has no attribute 'sleep'

The code :

import time
x = 1
t = 1
time = t + 1
while x == 1:


    print time
    if time >=10:
        time = t - 1
    elif time <= 0:
        time = t + 1
    time.sleep(time)

Edit:

import time
x = 1
t = 1
time1 = 0
while x == 1:

    if time1 == 10:
        time1 = time1 - 1
    elif time1 == 0:
        time1 = time1 + 1
    else :
        time1 = time1 + 1
    print time1
    time.sleep(time1)

So I changed the program around abit, so I almost works correctly. What it does is count to 10, then 9 then back to 10.
ex. 1,2,3,4,5,6,7,8,9,10,9,10,9,10
how can I set it so that the program increases time to ten then decreases to zero then increases again?

  • 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-06-02T08:49:45+00:00Added an answer on June 2, 2026 at 8:49 am

    You’re overriding the imported time module (line 1) by your own time variable (line 4). You can:

    • rename your time variable to something else

      import time
      x = 1
      t = 1
      time_passed = t + 1 # use "time_passed" instead of "time" for example
      while x == 1:
          print time_passed
          if time_passed >= 10:
              time_passed = t - 1
          elif time_passed <= 0:
              time_passed = t + 1
          time.sleep(time_passed)
      
    • alias the imported time module with import time as tm the use tm.sleep(time)

      import time as tm # alias the time module as "tm" for example
      x = 1
      t = 1
      time  = t + 1
      while x == 1:
          print time
          if time >= 10:
              time = t - 1
          elif time <= 0:
              time = t + 1
          tm.sleep(time) # use "tm" to refer to the module
      
    • only import sleep from time with from time import sleep and use sleep(time) instead

      from time import sleep # only import "sleep" from time, not the whole module
      x = 1
      t = 1
      time  = t + 1
      while x == 1:
          print time
          if time >= 10:
              time = t - 1
          elif time <= 0:
              time = t + 1
          sleep(time) # use "sleep" directly
      

    After fixing this, you also need to somehow remember that you need to either increase or decrease the time at the next iteration. For example:

    from time import sleep
    x = 1
    t = 1
    time  = t + 1
    incr = True
    while x == 1:
        print time
        if time >= 10:
            time = 9
            incr = False
        elif time <= 0:
            time = t + 1
            incr = True
        else:
            if incr:
                time = time + 1
            else:
                time = time - 1
        sleep(time)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time trying to accomplish core data and been having some
Here's what I'm trying to accomplish: I've got two tables, call them first and
I'm wondering if theres a best practice for what I'm trying to accomplish... First
I am trying to populate the text of a second EditText widget with the
I am trying to accomplish this but only my first where clause is getting
What I am trying to accomplish is having a fixed-width first div and a
Big picture: This is what I am trying to accomplish. Send a text message
First I will provide a quick overview of what I am trying to accomplish.
I'm trying to accomplish a simple task of creating a database with 2 tables
I'm trying to accomplish the following in ASP.Net: Create a WPF Canvas control Spin

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.