repl.it
@acwoss/

AptEveryElectricity

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from dataclasses import dataclass

@dataclass
class Character:
    name: str
    genre: str
    race: str

    def __str__(self):
        return (
            'Dados do personagem:\n'
            f'Nome: {self.name}\n'
            f'Gênero: {self.genre}\n'
            f'Raça: {self.race}\n'
        )

def create_character():
    print('New character:')

    info = {}

    for attribute, _type in Character.__annotations__.items():
        value = input(f'{attribute}: ')
        info[attribute] = _type(value)

    return Character(**info)

print(create_character())
Fetching token
?