Respuesta :
def first_character(txt):
return txt[0]
def all_but_first_character(txt):
return txt[1::]
print(first_character("hello"))
print(all_but_first_character("hello"))
I wrote my code in python 3.8. I hope this helps.
Following are the Program to the given question:
Program Explanation:
- Defining a two-method "first_character and all_but_first_character" that takes a string variable "t" into the parameter.
- In the first method, it returns the first character of the string.
- In the second method, it returns the string value except for the first character.
- At the last, we call both the methods.
Program:
def first_character(t):#defining a method first_character that takes a string variable in parameter
return t[0]#using return keyword that return first character of string
def all_but_first_character(t):#defining a method all_but_first_character that takes a string variable in parameter
return t[1::]#using return keyword that return string except first character
print(first_character("hello"))#calling method
print(all_but_first_character("hello"))#calling method
Output:
Please find the attached file.
Learn more:
brainly.com/question/19168392
