i have 2 list contaning 4 element
i must create 2 new list which contain 2 element
1st new list must contain an element from each original list
2nd list must also contain 2 element apart those of the 1st new list

Recommended Answers

All 7 Replies

Seems to be homework, so what have you coded so far?

i have 2 list contaning 4 element

= 8 elements total

I must create 2 new list which contain 2 element

= 4 elements total. What happens to the other 4 elements?

First when I read this post's title, I thought "this guy is crazy", dont judge me, at least not yet. Then I read the post, and I thought "What's he talking about?", and finally I read the title again, and I thought "What the heck does he want to do?". It involves a lot of things to do an application to predict the winner of world cup. Can you show us what you already have?

The title has nothing to do with the homework, but it gets the attention and fools the teacher. Clever?

have done this in python 2.6.2
its working but i want to add graphics to it


import time
import random

constant=1
FirstRun=True

def Intro ():
print ("welcome to Fifa 2010 world cup winner predicter,do you want to start (yes or no)")

def predict():

A=
B=
C=
D=
E=
F=
G=
H=
I=[]
J=[]
K=[]
L=[]
M=[]
N=[]
O=[]
P=[]
Q=[]
R=[]
S=[]
T=[]
U=[]
V=[]
W=[]
X=[]
Y=[]
Z=[]
print "* groups *"
time.sleep(2)
print "group A",A
print "group B",B
print "group C",C
print "group D",D
print "group E",E
print "group F",F
print "group G",G
print "group H",H
time.sleep(1)

A1= random.randint(0,3)
A2=A[A1]
A.remove(A2)
I.append(A2)

B1=random.randint(0,3)
B2=B[B1]
B.remove(B2)
J.append(B2)

A1=random.randint(0,2)
A2=A[A1]
J.append(A2)

B1=random.randint(0,2)
B2=B[B1]
I.append(B2)

C1= random.randint(0,3)
C2=C[C1]
C.remove(C2)
K.append(C2)

D1=random.randint(0,3)
D2=D[D1]
D.remove(D2)
L.append(D2)

C1=random.randint(0,2)
C2=C[C1]
L.append(C2)

D1=random.randint(0,2)
D2=D[D1]
K.append(D2)

E1= random.randint(0,3)
E2=E[E1]
E.remove(E2)
M.append(E2)

F1=random.randint(0,3)
F2=F[F1]
F.remove(F2)
N.append(F2)

E1=random.randint(0,2)
E2=E[E1]
N.append(E2)

F1=random.randint(0,2)
F2=F[F1]
M.append(F2)

G1= random.randint(0,3)
G2=G[G1]
G.remove(G2)
O.append(G2)

H1=random.randint(0,3)
H2=H[H1]
H.remove(H2)
P.append(H2)

G1=random.randint(0,2)
G2=G[G1]
P.append(G2)

H1=random.randint(0,2)
H2=H[H1]
O.append(H2)

print "* ROUND OF 16 *"
time.sleep(1)
print "1st eighth finals: winners 1A vs 2B",I
time.sleep(1)
print "2nd eighth finals: winners 1B vs 2A",J
time.sleep(1)
print "3rd eighth finals: winners 1C vs 2D",K
time.sleep(1)
print "4th eighth finals: winners 1D vs 2C",L
time.sleep(1)
print "5th eighth finals: winners 1E vs 2F",M
time.sleep(1)
print "6th eighth finals: winners 1F vs 2E",N
time.sleep(1)
print "7th eighth finals: winners 1G vs 2H",O
time.sleep(1)
print "8th eighth finals; winners 1H vs 2G",P
time.sleep(1)

I1= random.randint(0,1)
I2=I[I1]
Q.append(I2)

K1=random.randint(0,1)
K2=K[K1]
Q.append(K2)

J1= random.randint(0,1)
J2=J[J1]
R.append(J2)

L1=random.randint(0,1)
L2=L[L1]
R.append(L2)

M1= random.randint(0,1)
M2=M[M1]
S.append(M2)

O1=random.randint(0,1)
O2=O[O1]
S.append(O2)

N1= random.randint(0,1)
N2=N[N1]
T.append(N2)

P1=random.randint(0,1)
P2=P[P1]
T.append(P2)

print" * quarter finals *"
time.sleep(1)
print"1st quarter finals: winners 1st of 8 vs 3rd of 8",Q
time.sleep(1)
print"2nd quarter finals: winners 2nd of 8 vs 4th of 8",R
time.sleep(1)
print"3rd quarter finals: winners 5th of 8 vs 7th of 8",S
time.sleep(1)
print"4th quarter finals: winners 6th of 8 vs 8th of 8",T
time.sleep(1)

Q1= random.randint(0,1)
Q2=Q[Q1]
U.append(Q2)

S1=random.randint(0,1)
S2=S[S1]
U.append(S2)

R1= random.randint(0,1)
R2=R[R1]
V.append(R2)

T1=random.randint(0,1)
T2=T[T1]
V.append(T2)

print "* semi finals *"
time.sleep(1)
print "1st semi finals: winners 1st of 4 vs 3rd of 4",U
time.sleep(1)
print "2nd semi finals: winners 2nd of 4 vs 4th 0f 4",V
time.sleep(1)


U1= random.randint(0,1)
U2=U[U1]
U.remove(U2)
W.append(U2)
X.append(U)

V1=random.randint(0,1)
V2=V[V1]
V.remove(V2)
W.append(V2)
X.append(V)

time.sleep(1)
print "*************"
time.sleep(1)
print "finalist are: winners 1st semi vs 2nd semi",W
time.sleep(1)
print "minor final:loser 1st semi vs loser 2nd semi",X
time.sleep(2)

W1= random.randint(0,1)
W2=W[W1]
Y.append(W2)

X1=random.randint(0,1)
X2=X[X1]
X.remove(X2)
Z.append(X2)

print "standinds place:" ,"3rd",Z," 4th",X
time.sleep(1)
print "***FINAL***"
print "and the winner is ..."
time.sleep(2)
print "2010 fifa world cup final winner is:",Y
time.sleep(1)
print "***********"


while constant==1:
if FirstRun==True:
Intro()
FirstRun=False
else:
Answer =raw_input()
if Answer == "yes" :
predict()
print("do you want to retry (yes or no)")
else:
exit()


main()

import time
import random

constant=1
FirstRun=True

def Intro ():
     print ("welcome to Fifa 2010 world cup winner predicter,do you want to start (yes or no)")

def predict():
     
     A=['SOUTH AFRICA','MEXICO','URUGUAY','FRANCE']
     B=['ARGENTINA','NIGERIA','KOREA REPUBLIC','GREECE']
     C=['ENGLAND','USA','ALGERIA','SLOVENIA']
     D=['GERMANY','AUSTRALIA','SERBIA','GHANA']
     E=['NETHERLANDS','DENMARK','JAPAN','CAMEROON']
     F=['ITALY','PARAGUAY','NEW ZEALAND','SLOVAKIA']
     G=['BRAZIL','KOREA DPR','IVORY COAST','PORTUGAL']
     H=['SPAIN','SWITZERLAND','HONDURAS','CHILE']
     I=[]
     J=[]
     K=[]
     L=[]
     M=[]
     N=[]
     O=[]
     P=[]
     Q=[]
     R=[]
     S=[]
     T=[]
     U=[]
     V=[]
     W=[]
     X=[]
     Y=[]
     Z=[]
     print "*  groups  *"
     time.sleep(2)
     print "group A",A
     print "group B",B
     print "group C",C
     print "group D",D
     print "group E",E
     print "group F",F
     print "group G",G
     print "group H",H
     time.sleep(1)



     A1= random.randint(0,3)
     A2=A[A1]
     A.remove(A2)
     I.append(A2)

     B1=random.randint(0,3)
     B2=B[B1]
     B.remove(B2)
     J.append(B2)

     A1=random.randint(0,2)
     A2=A[A1]
     J.append(A2)

     B1=random.randint(0,2)
     B2=B[B1]
     I.append(B2)

     C1= random.randint(0,3)
     C2=C[C1]
     C.remove(C2)
     K.append(C2)

     D1=random.randint(0,3)
     D2=D[D1]
     D.remove(D2)
     L.append(D2)

     C1=random.randint(0,2)
     C2=C[C1]
     L.append(C2)

     D1=random.randint(0,2)
     D2=D[D1]
     K.append(D2)

     E1= random.randint(0,3)
     E2=E[E1]
     E.remove(E2)
     M.append(E2)

     F1=random.randint(0,3)
     F2=F[F1]
     F.remove(F2)
     N.append(F2)

     E1=random.randint(0,2)
     E2=E[E1]
     N.append(E2)

     F1=random.randint(0,2)
     F2=F[F1]
     M.append(F2)

     G1= random.randint(0,3)
     G2=G[G1]
     G.remove(G2)
     O.append(G2)

     H1=random.randint(0,3)
     H2=H[H1]
     H.remove(H2)
     P.append(H2)

     G1=random.randint(0,2)
     G2=G[G1]
     P.append(G2)

     H1=random.randint(0,2)
     H2=H[H1]
     O.append(H2)

     print        "*   ROUND OF 16   *"
     time.sleep(1)
     print "1st eighth finals: winners 1A vs 2B",I
     time.sleep(1)
     print "2nd eighth finals: winners 1B vs 2A",J
     time.sleep(1)
     print "3rd eighth finals: winners 1C vs 2D",K
     time.sleep(1)
     print "4th eighth finals: winners 1D vs 2C",L
     time.sleep(1)
     print "5th eighth finals: winners 1E vs 2F",M
     time.sleep(1)
     print "6th eighth finals: winners 1F vs 2E",N
     time.sleep(1)
     print "7th eighth finals: winners 1G vs 2H",O
     time.sleep(1)
     print "8th eighth finals; winners 1H vs 2G",P
     time.sleep(1)

     I1= random.randint(0,1)
     I2=I[I1]
     Q.append(I2)

     K1=random.randint(0,1)
     K2=K[K1]
     Q.append(K2)

     J1= random.randint(0,1)
     J2=J[J1]
     R.append(J2)

     L1=random.randint(0,1)
     L2=L[L1]
     R.append(L2)

     M1= random.randint(0,1)
     M2=M[M1]
     S.append(M2)

     O1=random.randint(0,1)
     O2=O[O1]
     S.append(O2)

     N1= random.randint(0,1)
     N2=N[N1]
     T.append(N2)

     P1=random.randint(0,1)
     P2=P[P1]
     T.append(P2)

     print" *   quarter finals   *"
     time.sleep(1)
     print"1st quarter finals: winners  1st of 8 vs 3rd of 8",Q
     time.sleep(1)
     print"2nd quarter finals: winners  2nd of 8 vs 4th of 8",R
     time.sleep(1)
     print"3rd quarter finals: winners  5th of 8 vs 7th of 8",S
     time.sleep(1)
     print"4th quarter finals: winners  6th of 8 vs 8th of 8",T
     time.sleep(1)

     Q1= random.randint(0,1)
     Q2=Q[Q1]
     U.append(Q2)

     S1=random.randint(0,1)
     S2=S[S1]
     U.append(S2)

     R1= random.randint(0,1)
     R2=R[R1]
     V.append(R2)

     T1=random.randint(0,1)
     T2=T[T1]
     V.append(T2)

     print "*  semi finals  *"
     time.sleep(1)
     print "1st semi finals: winners 1st of 4 vs 3rd of 4",U
     time.sleep(1)
     print "2nd semi finals: winners 2nd of 4 vs 4th 0f 4",V
     time.sleep(1)


     U1= random.randint(0,1)
     U2=U[U1]
     U.remove(U2)
     W.append(U2)
     X.append(U)

     V1=random.randint(0,1)
     V2=V[V1]
     V.remove(V2)
     W.append(V2)
     X.append(V)

     time.sleep(1)
     print "*************"
     time.sleep(1)
     print "finalist are: winners 1st semi vs 2nd semi",W
     time.sleep(1)
     print "minor final:loser 1st semi vs loser 2nd semi",X
     time.sleep(2)

     W1= random.randint(0,1)
     W2=W[W1]
     Y.append(W2)

     X1=random.randint(0,1)
     X2=X[X1]
     X.remove(X2)
     Z.append(X2)

     print "standinds place:" ,"3rd",Z," 4th",X
     time.sleep(1)
     print "***FINAL***"
     print "and the winner is ..."
     time.sleep(2)
     print "2010 fifa world cup final winner is:",Y
     time.sleep(1)
     print "***********"

          
while constant==1:
     if FirstRun==True:
          Intro()
          FirstRun=False
     else:
          Answer =raw_input()
          if Answer == "yes" :
               predict()
               print("do you want to retry (yes or no)")
          else:
                 exit()
 

main()

It is simpler to use loops. This should get you started. It has an example of using one list to hold all of the entrants, and how to print them using a loop.

import random
import time

def predict():

    A=['SOUTH AFRICA','MEXICO','URUGUAY','FRANCE']
    B=['ARGENTINA','NIGERIA','KOREA REPUBLIC','GREECE']
    C=['ENGLAND','USA','ALGERIA','SLOVENIA']
    D=['GERMANY','AUSTRALIA','SERBIA','GHANA']
    E=['NETHERLANDS','DENMARK','JAPAN','CAMEROON']
    F=['ITALY','PARAGUAY','NEW ZEALAND','SLOVAKIA']
    G=['BRAZIL','KOREA DPR','IVORY COAST','PORTUGAL']
    H=['SPAIN','SWITZERLAND','HONDURAS','CHILE']
    print "* groups *"
    time.sleep(2)

    group_list = [ A, B, C, D, E, F, G, H ]
    start_dec = ord('A')
    for group in group_list:
        print "group %s" %(chr(start_dec)), group
        start_dec += 1
    time.sleep(1)

    ##--------------------------------------------------------
    ##   you can use randint or random shuffle
    ##--------------------------------------------------------
    first_round = []
    for group in group_list:
        random.shuffle(group)
##        print group     ## uncomment if you want to see the results of random.shuffle
        first_round.append([ group[0], group[1] ])
##    print first_round
    print "\n* ROUND OF 16 *"
    time.sleep(1)

    ## letters corresponding to the lists
    letters = ["A", "B", "C", "D", "E", "F", "G", "H"]
    ## numbers formatted for printing
    numbers = ["1st", "2nd", "3rd"]
    for j in range(4, 9):
        numbers.append("%dth" % (j))
    ctr = 0   
    for x in range(4):
       print "%s eighth finals: winners 1%s vs 2%s" % \
                 (numbers[ctr], letters[ctr], letters[ctr+1])
       print "%s eighth finals: winners 1%s vs 2%s" % (\
                 numbers[ctr+1], letters[ctr+1], letters[ctr])
       ctr += 2

##--------------------------------------------------------
## note that your statement
## print "1st eighth finals: winners 1A vs 2B",I
## uses "I" before it is defined
##--------------------------------------------------------

predict()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.