Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1251

Python • Manipulate % variables Python

$
0
0
Hi,

I am running the following code to help with a robot project.

Code:

import timeimport boardimport busioimport adafruit_adxl34xi2c = busio.I2C(board.SCL, board.SDA)accelerometer = adafruit_adxl34x.ADXL345(i2c)while True:    print("%f %f %f"%accelerometer.acceleration)    time.sleep(1)
It outputs 3 numbers, but I want to use only the 3rd accelerometer output %f in my project.
How do I extract the last number from the %f %f %f bit?

Thanks

CJ

Statistics: Posted by Candyjet — Thu Jan 25, 2024 12:31 pm



Viewing all articles
Browse latest Browse all 1251

Trending Articles