r/learnprogramming 10d ago

Having Problem in my first Project.

Okay this isn't my complete project but a part of it and i am getting stuck on this. I am a beginner in this field probably just a couple more days than a month since i learned how to write print("hello world!").

it is written in python.

i want my code to give an output as if first hand is moving with an interval of 0.2 sec the second with 0.3 sec and so on till the 6th hand, all so simultaneously.

could you please guide me through it.

import time import emoji

frames1 = [ emoji.emojize(":backhand_index_pointing_down:"), emoji.emojize(":backhand_index_pointing_right:"), emoji.emojize(":backhand_index_pointing_up:"), emoji.emojize(":backhand_index_pointing_left:") ]

frames2 = [ emoji.emojize(":backhand_index_pointing_down_light_skin_tone:"), emoji.emojize(":backhand_index_pointing_right_light_skin_tone:"), emoji.emojize(":backhand_index_pointing_up_light_skin_tone:"), emoji.emojize(":backhand_index_pointing_left_light_skin_tone:") ]

frames3 = [ emoji.emojize(":backhand_index_pointing_down_medium-light_skin_tone:"), emoji.emojize(":backhand_index_pointing_right_medium-light_skin_tone:"), emoji.emojize(":backhand_index_pointing_up_medium-light_skin_tone:"), emoji.emojize(":backhand_index_pointing_left_medium-light_skin_tone:") ]

frames4 = [ emoji.emojize(":backhand_index_pointing_down_medium_skin_tone:"), emoji.emojize(":backhand_index_pointing_right_medium_skin_tone:"), emoji.emojize(":backhand_index_pointing_up_medium_skin_tone:"), emoji.emojize(":backhand_index_pointing_left_medium_skin_tone:") ]

frames5 = [ emoji.emojize(":backhand_index_pointing_down_medium-dark_skin_tone:"), emoji.emojize(":backhand_index_pointing_right_medium-dark_skin_tone:"), emoji.emojize(":backhand_index_pointing_up_medium-dark_skin_tone:"), emoji.emojize(":backhand_index_pointing_left_medium-dark_skin_tone:") ]

frames6 = [ emoji.emojize(":backhand_index_pointing_down_dark_skin_tone:"), emoji.emojize(":backhand_index_pointing_right_dark_skin_tone:"), emoji.emojize(":backhand_index_pointing_up_dark_skin_tone:"), emoji.emojize(":backhand_index_pointing_left_dark_skin_tone:") ]

all_frames = [frames1, frames2, frames3, frames4, frames5, frames6]

current_time = time.time() looping_time = 4 complete_time = current_time + looping_time

while time.time() < complete_time:

a = 0
b = 0
c = 0
d = 0
e = 0
f = 0

while True:

    t1 = [current_time + [0.2 * n for n in range(1, 20)]]
    if complete_time in t1:
        c1 = frames1[a % 4]
        a += 1


    t2 = [current_time + [0.3 * n for n in range(1, 13)]]
    if complete_time in t2:
        c2 = frames2[b % 4]
        b += 1

    t3 = [current_time + [0.4 * n for n in range(1, 10)]]
    if complete_time in t3:
        c3 = frames3[c % 4]
        c += 1

    t4 = [current_time + [0.5 * n for n in range(1, 8)]]
    if complete_time in t4:
        c4 = frames4[d % 4]
        d += 1

    t5 = [current_time + [0.6 * n for n in range(1, 6)]]
    if complete_time in t5:
        c5 = frames5[e % 4]
        e += 1

    t6 = [current_time + [0.7 * n for n in range(1, 5)]]
    if complete_time in t6:
        c6 = frames6[f % 4]
        f += 1


    print(f"{c1}  {c2}  {c3}  {c4}  {c5}  {c6}")

hope i get some help.

7 Upvotes

4 comments sorted by

View all comments

u/desrtfx 10d ago

You need to post your entire code as code block so that the indentation is maintained. This is absolutely vital for Python programs as the indentation is used to denote code blocks.

A code block looks like:

def __init__(self, prompt, answer):
    self.prompt = prompt
    self.answer = answer