question number one:
The function gets a list of strings of even length. The function returns a string that contains the list members in the even positions, separated by a comma and a space, as well as the last member with the caption and in front of it.
my try is:
[]
I dont get it, no matter what I try, I wont get anything other than the []...
I dont need a solution, What I need is a tip, what to change here ( only one thing, ill try to understand alone the rest ).
EDIT: I know this question doesnt include the and thingy, but I first want to see that im getting something instead of [] at output. when ill get it, ill add it with join function, but first of all, i want to fix this code so it will work.
________________________________________________________________________________________________________
second question:
Write a function called shift_left. The function receives a list of length 3 and returns a new list moved one step to the left.
Function definition === def shift_left (my_list):
Examples of running the shift_left function
>>> shift_left ([0, 1, 2])
[1, 2, 0]
>>> shift_left (['monkey', 2.0, 1])
[2.0, 1, 'monkey']
my try:
I managed to find a solution for this one online, but it concluded 2 definitions, I dont think it should be part of the solution... if there is any other thing, ill be happy for a tip also, only a small tip so I can continiue.
_____________________________________________________________________________________________________
now, I know im not using BBCODE and i was told twice in my threads not to post without it, but seriously, the link https://python-forum.io/misc.php?action=help&hid=25 doesnt say at all how to use it... all I understood from there, that i need to put python between my code and thats it... the explanation there is not really understandable, i cant post in bbcode because of it... all i can do is the code thingy... if its not allowed, then i guess ill be stuck ( cus you must use bbcode as i understood ).
The function gets a list of strings of even length. The function returns a string that contains the list members in the even positions, separated by a comma and a space, as well as the last member with the caption and in front of it.
my try is:
def format_list(my_list): """ This function returns the words in the list which is in the even side. :param my_list: The list of the project. :type my_list: str, int, float :rtype: str, int, float :return: The result of the list on the even only. """ my_list = [] if len(my_list) % 2 == 0: return my_list[0::2] new_list = format_list(my_list=["hydrogen", "helium", "lithium", "beryllium", "boron", "magnesium"]) print(new_list)output is:
[]
I dont get it, no matter what I try, I wont get anything other than the []...
I dont need a solution, What I need is a tip, what to change here ( only one thing, ill try to understand alone the rest ).
EDIT: I know this question doesnt include the and thingy, but I first want to see that im getting something instead of [] at output. when ill get it, ill add it with join function, but first of all, i want to fix this code so it will work.
________________________________________________________________________________________________________
second question:
Write a function called shift_left. The function receives a list of length 3 and returns a new list moved one step to the left.
Function definition === def shift_left (my_list):
Examples of running the shift_left function
>>> shift_left ([0, 1, 2])
[1, 2, 0]
>>> shift_left (['monkey', 2.0, 1])
[2.0, 1, 'monkey']
my try:
def shift_left(my_list): """ This function moves the list with 3 numbers one step to the left. If it was 0 1 2, then it will be 1, 2, 0. :param my_list: The numbers of the list I will choose. :type my_list: str, int, float :rtype :return: the result of the list with one step left. """ my_list = [param1, param2, param3] new_list = my_list[::-1]well, to be honest ,at this one, I dont have the other tries I had, I had in here 3 solutions, only 1 worked, but it wasnt according to how it should be... the one that worked If I wrote a string inside the my_list at the definition at the end, it would have worked ( i cant have it since it was before hours ago ). the other two are long long gone... this one I just left it like that and went on to the next question ( which is the first question up there, I did it opposite here, but it doesnt matter ).
I managed to find a solution for this one online, but it concluded 2 definitions, I dont think it should be part of the solution... if there is any other thing, ill be happy for a tip also, only a small tip so I can continiue.
_____________________________________________________________________________________________________
now, I know im not using BBCODE and i was told twice in my threads not to post without it, but seriously, the link https://python-forum.io/misc.php?action=help&hid=25 doesnt say at all how to use it... all I understood from there, that i need to put python between my code and thats it... the explanation there is not really understandable, i cant post in bbcode because of it... all i can do is the code thingy... if its not allowed, then i guess ill be stuck ( cus you must use bbcode as i understood ).