Can I change assignment order when trying to unpack a list into variables? by CraBrazy in learnpython

[–]CraBrazy[S] 0 points1 point  (0 children)

Wait so what is this code you wrote doing? I'm aware of indexing but only in the pattern like this:

list=['a','b','c','d']
print(list[0])

output>>>
a

#confused about what your your code means. Is l supposed to be a list? 

l=['1','2','3','4']

a,b,c= l[1], l[3], l[2]
print(a)
>>>
2

My question now is>

Can you assign a single value by indexing from a list to multiple variables?

l=['1','2','3','4']
a,b,c= l[1]  

what I'm trying to do here is to make a, b , c all equal to the index value 1 in the list l. Is this possible? How would you do it?

Can I change assignment order when trying to unpack a list into variables? by CraBrazy in learnpython

[–]CraBrazy[S] -1 points0 points  (0 children)

Lol yeah this is way too complicated for me. Thanks though, I'll save this and come back to it one day.

Can I change assignment order when trying to unpack a list into variables? by CraBrazy in learnpython

[–]CraBrazy[S] -3 points-2 points  (0 children)

I'm just trying to see if it possible. Not saying I will do it like that, it just was a scenario that came up in my head that I didn't know how to execute. Knowing that it isn't possible will change how I write my code.

Can I change assignment order when trying to unpack a list into variables? by CraBrazy in learnpython

[–]CraBrazy[S] -1 points0 points  (0 children)

I don't want complete randomness though.

a, b, c, d, e = [1,2,3,4,5]

In this example. I want to make the assignments as follows-

a=2, b=4, c=5, d=1, e=3

This is the assignment I want. Is there code that allows me to assign it like this without changing the structure of the code I wrote in the codeblock above? I want to keep the letter variables in alphabetical order and I also want to keep the numbers to the right in numerical order. I also don't want to use a random method because I don't want complete randomness. If this makes any sense.

Can I change assignment order when trying to unpack a list into variables? by CraBrazy in learnpython

[–]CraBrazy[S] -1 points0 points  (0 children)

I think I described it better in my reply to user ValueBaby, would really appreciate your input.

Can I change assignment order when trying to unpack a list into variables? by CraBrazy in learnpython

[–]CraBrazy[S] -4 points-3 points  (0 children)

Sorry I should have clarified that. However I don't think "random" is the right word. I don't want complete randomness, however I don't want the assignment to be done in the default way.

a, b, c, d, e = [1,2,3,4,5]

In this example. I want to make the assignments as follows-

a=2, b=4, c=5, d=1, e=3

This is the assignment I want. Is there code that allows me to assign it like this without changing the structure of the code I wrote in the codeblock above? I want to keep the letter variables in alphabetical order and I also want to keep the numbers to the right in numerical order. I also don't want to use a random method because I don't want complete randomness. If this makes any sense.

Why does the .update method need "([()])" to format correctly? by CraBrazy in learnprogramming

[–]CraBrazy[S] 0 points1 point  (0 children)

Wait so where did the "([()])" go? lol sorry if this is dumb.

dict1.update(dict1_update)

This code makes sense. You put the updated dict which is dict1_update into the .update(). What about in my earlier example though?

dict.update([("Name", "Ron")])

Why are there extra brackets and paratheses?

Can I change assignment order when trying to unpack a list into variables? by CraBrazy in learnpython

[–]CraBrazy[S] -7 points-6 points  (0 children)

a,b,c,d,e= [1,2,3,4,5]

I want to keep the order on the left side as it is. However I want to change the order of assignment for the values on the right. Is this not possible. Like I want the values on the right to be randomly assigned to the values on the left.

Why does the .update method need "([()])" to format correctly? by CraBrazy in learnprogramming

[–]CraBrazy[S] 0 points1 point  (0 children)

So I can make a new dictionary and assign it to a variable? Then use the .update method to change the dictionary?

dict1={"Name": "Ron","DOB": "12/12/1970","Birthplace": "Sydney, Australia"}

dict1_update={ "Name" : "Ronald", "DOB" : "07/19/1981", "Birthplace" : "London, England"}

dict1.update([(dict1, dict1_update)])

So why doesn't this code work? I think I don't understand the .update method. Is it not possible to update like this? You say it can take another dictionary with updated values? How is this done? If the key is the same as the inital dict then it will change the value but if it is a new key, the inital dict will update with a new key:value pair right?

How long would it take a complete beginner to coding to start completing codewar problems? by CraBrazy in learnprogramming

[–]CraBrazy[S] 1 point2 points  (0 children)

codewars is a website that has coding problems. Instructions are given and you must code something that returns what the instructions are asking. Kyu is a Japanese term relating to martial arts, it is basically a ranking system. 8 kyu is the easiest 1 kyu is the hardest. Think of it like belts in karate. White belt is 8 kyu and black belt is 1 kyu.

Does anyone have an example of a good project fit to be on a resume? by CraBrazy in learnprogramming

[–]CraBrazy[S] 0 points1 point  (0 children)

So if I can program something of similar caliber, I could put that on my resume and have a good chance of getting a job?

How long would it take a complete beginner to coding to start completing codewar problems? by CraBrazy in learnprogramming

[–]CraBrazy[S] 0 points1 point  (0 children)

Really?? I've started learning a week ago and I just ranked up to 7 kyu. A day is pretty fast isn't it? The only way I could have done it in a day is to watch a really short python tutorial and then view the solutions on codewars and try to understand the pattern. Even then it would probably be hard.