how to pack analog and digital inputs to send them on serial output

I wrote a python program on my laptop using the pygame module and I would like to use arduino as an input device. I would like to manipulate 4 variables: two would be integer and 2 would be boolean, so I connect to my arduino board 2 potentiometers as analog inputs and 2 switch buttons as digital inputs.
even if I can read the inputs from arduino I'm not really sure how to pack them and send them as an output through the serial port. the problem is that I don't really know how should I aggregate multiple inputs in just one output to send to python program.
I wrote this code where I separate each data with a '.' but I've had some troubles unpacking that information on the python program.
which ways would you reccomend me?
thank you!

this is the code I wrote

const int button1 = 2;
const int button2 = 4;
int state_button1 = 0;
int state_button2 = 0;
int sensorValue1 = 0;
int sensorValue2 = 0;

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// initialize digital inputs
pinMode(button1, INPUT);
pinMode(button2, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
// read analog inputs from 2 potentiometers at A0 and A1
sensorValue1 = analogRead(A0);
sensorValue2 = analogRead(A1);
// read digital inputs from 2 buttons at 2,4
state_button1 = digitalRead(button1);
state_button2 = digitalRead(button2);

Serial.print(sensorValue1);
Serial.print(".");
Serial.print(sensorValue2);
Serial.print(".");
Serial.print(state_button1);
Serial.print(".");
Serial.print(state_button2);
Serial.println();
}

Google "C struct".

should I make a structure with all the input variables and print it on the Serial output?
can I unpack that with python then?

I tried but I get an error when I try to print on the serial outut my structure.
it says: no matching function for call to 'HardwareSerial::println(variable_structure)'

aieio:
should I make a structure with all the input variables and print it on the Serial output?
can I unpack that with python then?

I tried but I get an error when I try to print on the serial outut my structure.
it says: no matching function for call to 'HardwareSerial::println(variable_structure)'

It seems to me that you need help with Python more than with the Arduino

Unless you really need the extra performance just send the data using Serial.print(). It makes debugging much easier.

Have a look at this Python - Arduino demo

...R

Robin2:
Unless you really need the extra performance just send the data using Serial.print(). It makes debugging much easier.

Have a look at this Python - Arduino demo

...R

thank you! that helped!