How to remove a specific randomly chosen element from a list?











up vote
1
down vote

favorite












So I'm doing a simple python game for a school project and it is like a playing card game. But i don't know how to remove the card I've played.
Basically, I have a pack of 7 cards and i randomly choose one card to be played if my attack > than opponents defese I won, and my card should not be used anymore. I'm doing all based on lists and strings, How can I remove the card who was randomly chosen?



 baralho1=        
baralho1 += random.sample(MasterList, 7)
print("nEste é o teu baralho:n",baralho1)
baralho2=
baralho2 += random.sample(MasterList, 7)
a=random.choice(baralho1)


How do I remove "a" from the "baralho1"?










share|improve this question







New contributor




Henrique Sousa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2




    it probably would be a better idea to generate pseudo-random index and pop card from list using it
    – Azat Ibrakov
    Nov 10 at 16:13










  • Do you want to remove 1 occurence of a, or all occurences?
    – user202729
    Nov 10 at 16:17










  • @user202729 all!!
    – Henrique Sousa
    Nov 10 at 18:03















up vote
1
down vote

favorite












So I'm doing a simple python game for a school project and it is like a playing card game. But i don't know how to remove the card I've played.
Basically, I have a pack of 7 cards and i randomly choose one card to be played if my attack > than opponents defese I won, and my card should not be used anymore. I'm doing all based on lists and strings, How can I remove the card who was randomly chosen?



 baralho1=        
baralho1 += random.sample(MasterList, 7)
print("nEste é o teu baralho:n",baralho1)
baralho2=
baralho2 += random.sample(MasterList, 7)
a=random.choice(baralho1)


How do I remove "a" from the "baralho1"?










share|improve this question







New contributor




Henrique Sousa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2




    it probably would be a better idea to generate pseudo-random index and pop card from list using it
    – Azat Ibrakov
    Nov 10 at 16:13










  • Do you want to remove 1 occurence of a, or all occurences?
    – user202729
    Nov 10 at 16:17










  • @user202729 all!!
    – Henrique Sousa
    Nov 10 at 18:03













up vote
1
down vote

favorite









up vote
1
down vote

favorite











So I'm doing a simple python game for a school project and it is like a playing card game. But i don't know how to remove the card I've played.
Basically, I have a pack of 7 cards and i randomly choose one card to be played if my attack > than opponents defese I won, and my card should not be used anymore. I'm doing all based on lists and strings, How can I remove the card who was randomly chosen?



 baralho1=        
baralho1 += random.sample(MasterList, 7)
print("nEste é o teu baralho:n",baralho1)
baralho2=
baralho2 += random.sample(MasterList, 7)
a=random.choice(baralho1)


How do I remove "a" from the "baralho1"?










share|improve this question







New contributor




Henrique Sousa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











So I'm doing a simple python game for a school project and it is like a playing card game. But i don't know how to remove the card I've played.
Basically, I have a pack of 7 cards and i randomly choose one card to be played if my attack > than opponents defese I won, and my card should not be used anymore. I'm doing all based on lists and strings, How can I remove the card who was randomly chosen?



 baralho1=        
baralho1 += random.sample(MasterList, 7)
print("nEste é o teu baralho:n",baralho1)
baralho2=
baralho2 += random.sample(MasterList, 7)
a=random.choice(baralho1)


How do I remove "a" from the "baralho1"?







python-3.x






share|improve this question







New contributor




Henrique Sousa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Henrique Sousa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Henrique Sousa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 10 at 16:10









Henrique Sousa

91




91




New contributor




Henrique Sousa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Henrique Sousa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Henrique Sousa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 2




    it probably would be a better idea to generate pseudo-random index and pop card from list using it
    – Azat Ibrakov
    Nov 10 at 16:13










  • Do you want to remove 1 occurence of a, or all occurences?
    – user202729
    Nov 10 at 16:17










  • @user202729 all!!
    – Henrique Sousa
    Nov 10 at 18:03














  • 2




    it probably would be a better idea to generate pseudo-random index and pop card from list using it
    – Azat Ibrakov
    Nov 10 at 16:13










  • Do you want to remove 1 occurence of a, or all occurences?
    – user202729
    Nov 10 at 16:17










  • @user202729 all!!
    – Henrique Sousa
    Nov 10 at 18:03








2




2




it probably would be a better idea to generate pseudo-random index and pop card from list using it
– Azat Ibrakov
Nov 10 at 16:13




it probably would be a better idea to generate pseudo-random index and pop card from list using it
– Azat Ibrakov
Nov 10 at 16:13












Do you want to remove 1 occurence of a, or all occurences?
– user202729
Nov 10 at 16:17




Do you want to remove 1 occurence of a, or all occurences?
– user202729
Nov 10 at 16:17












@user202729 all!!
– Henrique Sousa
Nov 10 at 18:03




@user202729 all!!
– Henrique Sousa
Nov 10 at 18:03












1 Answer
1






active

oldest

votes

















up vote
0
down vote














How do I remove "a" from the "baralho1"?




baralho1.remove(a)


Please read the documentation on mutable sequence types.






share|improve this answer





















  • Thank you so much! It Worked!!! Now I can finish my project
    – Henrique Sousa
    Nov 10 at 18:08











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Henrique Sousa is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240821%2fhow-to-remove-a-specific-randomly-chosen-element-from-a-list%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote














How do I remove "a" from the "baralho1"?




baralho1.remove(a)


Please read the documentation on mutable sequence types.






share|improve this answer





















  • Thank you so much! It Worked!!! Now I can finish my project
    – Henrique Sousa
    Nov 10 at 18:08















up vote
0
down vote














How do I remove "a" from the "baralho1"?




baralho1.remove(a)


Please read the documentation on mutable sequence types.






share|improve this answer





















  • Thank you so much! It Worked!!! Now I can finish my project
    – Henrique Sousa
    Nov 10 at 18:08













up vote
0
down vote










up vote
0
down vote










How do I remove "a" from the "baralho1"?




baralho1.remove(a)


Please read the documentation on mutable sequence types.






share|improve this answer













How do I remove "a" from the "baralho1"?




baralho1.remove(a)


Please read the documentation on mutable sequence types.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 16:14









ShadowRanger

55.6k44789




55.6k44789












  • Thank you so much! It Worked!!! Now I can finish my project
    – Henrique Sousa
    Nov 10 at 18:08


















  • Thank you so much! It Worked!!! Now I can finish my project
    – Henrique Sousa
    Nov 10 at 18:08
















Thank you so much! It Worked!!! Now I can finish my project
– Henrique Sousa
Nov 10 at 18:08




Thank you so much! It Worked!!! Now I can finish my project
– Henrique Sousa
Nov 10 at 18:08










Henrique Sousa is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















Henrique Sousa is a new contributor. Be nice, and check out our Code of Conduct.













Henrique Sousa is a new contributor. Be nice, and check out our Code of Conduct.












Henrique Sousa is a new contributor. Be nice, and check out our Code of Conduct.















 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240821%2fhow-to-remove-a-specific-randomly-chosen-element-from-a-list%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma