sending numbers to arduino via python

Hi - I figured out how to send numbers from 0-9 to the arduino from python using'0' . Is there a simple way to instead send a value larger than 0-9 to the arduino. Right now I turn on an LED to monitor whether the it is working. My plan is to turn on a stepper motor for a certain number of iterations. I want python to send the number of iterations to the arduino. Then I can assign that value (such as 32500) to the iteration counter that controls the motor. FYI I am a new to programming and dont have a great grasp of integers,bytes,strings, etc.

Heres the python code:

import serial
import time

arduino = serial.Serial(2, 9600, timeout = 1)

while 1:
    command = str.encode('1')

and the Arduino Code:

int led = 4;
int state = 0;

void setup() {
  pinMode(led, OUTPUT);

void loop() {
  if (Serial.available() > 0) {
      state = '0';
      if  (state == 1){
      digitalWrite(led, HIGH);
      digitalWrite(led, LOW);

    while (Serial.available() > 0)

    command = str.encode('1')

What type is command supposed to be? What does encode do? Why do you think you need to encode anything?

    while (Serial.available() > 0)

You sent one character. You read one character. Why do you think that you need to dump random amounts of unread data?

The examples in serial input basics are simple reliable ways for the Arduino to receive data.

You may also be interested in this Python-Arduino demo.