Irish Wolf
Irish Wolf

Reputation: 211

how to break lines when I concatenate strings in django

hy guys, I needed again of the help of you. Now i want to make a break line when i concatenate strings, i tried to do of this way:

    r['placa_desc'] = PessoaFrota(request,dbcur).get_placa_choices(r.get('placa'))
    if r.get('placa_desc'):
        r['placa'] =   \n + r.get('placa_desc')[0]

but when i try to make this, i got this error:

Exception Value:
unexpected character after line continuation character (views.py, line 250)

Can somebody help me?

Upvotes: 1

Views: 2457

Answers (2)

virhilo
virhilo

Reputation: 6793

you missed '', it should be:

 r['placa_desc'] = PessoaFrota(request,dbcur).get_placa_choices(r.get('placa'))
    if r.get('placa_desc'):
        r['placa'] =   '\n' + r.get('placa_desc')[0]

Upvotes: 2

Spacedman
Spacedman

Reputation: 94182

You need to quote your \n:

r['placa'] =   \n + r.get('placa_desc')[0]

r['placa'] =   "\n" + r.get('placa_desc')[0]

or python thinks the \ is a continuation character. Try that.

Upvotes: 3

Related Questions