I’m developing a python R.A. generator, and I’m having trouble printing a sequence

Asked

Viewed 41 times

-2

Generate a record sequence

lote = int ( input ( 'Digite o nº do lote: ' ) )
tipo = int ( input ( 'Digite o tipo da placa: ' ) )
sequencial = int ( input ( 'Digite a o primeiro nº: ' ) )

tipo1 = "{:04n}".format ( tipo )
sequencial1 = "{:05n}".format ( sequencial )

num = int ( lote + tipo + sequencial )

def digital_root(num) :
    x = sum ( int ( digit ) for digit in str ( num ) )
    if x < 10 :
        return x
    else :
        return digital_root ( x )

print('R.A.: ', lote, tipo1, sequencial1, digital_root ( num ))

Example

Entree

Enter the lot number: 28

Type the plate type: 100

Type the first number: 921

In print output a sequence like this:

R.A.: 28 0100 00921 5

R.A.: 28 0100 00922 6

R.A.: 28 0100 00923 7

R.A.: 28 0100 00924 8

R.A.: 28 0100 00925 9

R.A.: 28 0100 00926 1

R.A.: 28 0100 00927 2

R.A.: 28 0100 00928 3

R.A.: 28 0100 00929 4

R.A.: 28 0100 00930 5

  • Please edit your question by giving an example of your code input and what the output is. This information is unclear.

1 answer

-2

The desired result can be achieved using the following function:

 print('R.A.: {} {} {} {}'.format(lote, tipo1, sequencial1, digital_root ( num )))
 # R.A.: 28 0100 00921 5

I hope I’ve helped.

  • Thanks Danizavtz. But the result should give a sequence equal to the example I passed above. with the exception of spaces between lines.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.