[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Python 2.7 experts ?????

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 12
Thread images: 1

File: done.jpg (19KB, 257x390px) Image search: [Google]
done.jpg
19KB, 257x390px
guys I know im supposed to do this but i've been pulling my hair out for the past 3 hours can anyone help ? I'm trying to create a Object oriented program that will :

Each user starts with a list of numbers from 1 to 6. They then take turns throwing a dice, aiming to throw each number in the list.

Show the numbers of the user each time around the main game loop, showing an X for a number they have already, e.g.Starting

[1][2][3][4][5][6]

after 3 throws:

[1][X][X][4][X][6]

The game is complete when the player gets all numbers in the list.
>>
For starters
[1,2,3,4,5,6]
>>
>>59608779
I'm too lazy to do your homework.
>>

import random

class game:
nums = [x for x in range(1,7)]

def throw(self):
t = random.randint(1,6)
print(t)
self.nums = [x for x in self.nums if x != t]

def isFinished(self):
return (len(self.nums) == 0)

b = game()
while not b.isFinished():
b.throw()

print(b.nums)
>>
Uhm thanks !!!! that'll be more than enough the code is a bit complicated but i'll understand
>>
Create class for player. Player has number list containing numbers 1 to 6. You can give them names or other stupid shit if you want.
Put each created player into a list.
Create variables. One being turn, set to 0. Another being winner, set to empty string.
Put program in never ending loop.
Get player object. A = player_list[ turn % len(player_list)]
...
Do shit
...
Turn += 1
Break out of loop if player number list is empty
Print the faggot winner

There I did half your work.
Also
>Python 2
>>
>>59609002
Thanks !!!
>>
So each player is playing with the same random list?
>>
>>59609164
Yes the other player is the computer but they are playing from the same list
>>
why don't you just install gentoo then run

import homework

homework.run()
>>
import rope

hang.outofawindow()
>>
>>59609228
thanks
Thread posts: 12
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.