Daniel Ezekiel
Daniel Ezekiel

Reputation: 133

Add the empty space in the string

I am working on the code to input the numbers in the string self.EPG_DIGIT_NUMBER when I'm pressing on the keyboard number buttons. I would like to add the empty string like this in each time when I press on the keyboard number buttons.

DIGIT_BUTTONS = range(58, 68)

if action.getId() in DIGIT_BUTTONS:
    EPG_DIGIT_NUMBER = len(self.EPG_DIGIT)

    if EPG_DIGIT_NUMBER <= 2:
       self.EPG_DIGIT_NUMBER += str(action.getId() - 58)
    self.EPG_DIGIT += 1
    self.getControl(413).setLabel('[B]' + self.EPG_DIGIT_NUMBER + '[/B]')

When I press on the keyboard numbers 1,0,3, it will show 103 in the string. What I want to achieve is when I press on the keyboard number buttons 1,0,3, I want to make the string to show something is like: 1 0 3. How I can do that?

Upvotes: 0

Views: 115

Answers (2)

Neha
Neha

Reputation: 3650

You can use ' '.join(str("your_string_here"))

Upvotes: 1

whackamadoodle3000
whackamadoodle3000

Reputation: 6748

Change self.EPG_DIGIT_NUMBER += str(action.getId() - 58) to self.EPG_DIGIT_NUMBER += (str(action.getId() - 58)+' ') so that a space gets appended to the end of the number after each time a number is pressed.

Upvotes: 1

Related Questions