0

Good day

I am a noob and need a very simple python program part, unfortunately it does not work for me yet.

The idea: A list with 6 values should be at each keyboard stroke (1-6), the respective value is obtained and then output. My idea was to use an if-condition or a while-loop, but both don't work. The Programm should run constantly.

Implementation was done with Python:

import keyboard

joint_q = [-1.00, -1.00, -2.00, -0.00, 1.00, 0.00]

    while True:
    
        if keyboard.is_pressed('1'):
            joint_q[0] += 0.0001
            print(joint_q)
        if keyboard.is_pressed('2'):
            joint_q[1] += 0.0001
            print(joint_q)
        if keyboard.is_pressed('3'):
            joint_q[2] += 0.0001
            print(joint_q)
        if keyboard.is_pressed('4'):
            joint_q[3] += 0.0001
            print(joint_q)
        if keyboard.is_pressed('5'):
            joint_q[4] += 0.0001
            print(joint_q)
        if keyboard.is_pressed('6'):
            joint_q[5] += 0.0001
            print(joint_q)

When I start my Programm with pycharm, it "just finished", but i want it all the time in the "while True: loop" an constantly updating my list joint_q.

sincerely Stressor

Stressor
  • 1
  • 2

0 Answers0