Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

how to write a class with inputs in python

class Person:
     """
     A representation of a person 
     Attributes:
         Firstname(string)
         Lastname(String)
     """
     def __init__(self, firstname, lastname):
         self.firstname = firstname
         self.lastname = lastname

     def show_full_name(self):
         return self.firstname + ' ' + self.lastname

     @classmethod
     def get_user_input(self):
         while 1:
             try:
                 firstname = input('Enter first name: ')
                 lastname = input('Enter last name')
                 return self(firstname,lastname)
             except:
                 print('Invalid input!')
                 continue

#creating a person object and returning their full name
person3 = Person.get_user_input()
person3.show_full_name()
Comment

PREVIOUS NEXT
Code Example
Typescript :: python requests exceptions 
Typescript :: Hide all elements with class jQuery 
Typescript :: how to check constraints on a table in sql oracle 
Typescript :: block robots from crawling 
Typescript :: typeorm @unique 
Typescript :: how to access elements in bash array 
Typescript :: sort array of objects by 2 key value 
Typescript :: requests to check is url exists in python using function 
Typescript :: nuxt @use "sass:math"; 
Typescript :: woocommerce sql query pulls products from category 
Typescript :: check return type jest 
Typescript :: how to see what program is using a port 
Typescript :: fill a list with input python 
Typescript :: get all the game objects in a scene unity 
Typescript :: beautifulsoup search for elements with attributes 
Typescript :: how to declare a boolean in typescript 
Typescript :: contents links python jupyter 
Typescript :: react native elements input phone number max characters 
Typescript :: when i console log a obj its printing object 
Typescript :: check all elements in list are false python 
Typescript :: reactnative upload image axios 0.66 
Typescript :: class typescript constructor 
Typescript :: filter array of objects react 
Typescript :: constructor interface typescript 
Typescript :: material ui styled components with theme 
Typescript :: Error: Missing "key" prop for element in iterator 
Typescript :: typescript for loop key value pai 
Typescript :: get key value typescript 
Typescript :: init tsconfig file 
Typescript :: declare object array in typescript 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =