Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > fr.comp.lang.python > #3372

Re: Pourquoi ca ne marche pas

Path csiph.com!weretis.net!feeder8.news.weretis.net!border2.nntp.ams1.giganews.com!nntp.giganews.com!buffer2.nntp.ams1.giganews.com!buffer1.nntp.ams1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date Mon, 09 Nov 2020 12:08:26 -0600
Newsgroups fr.comp.lang.python
Subject Re: Pourquoi ca ne marche pas
X-poster PEAR::Net_NNTP v1.5.0 (stable)
From vdperic <nospam_vdperic@yahoo.fr.invalid>
References <KZWdnRtmc8WAsjXCnZ2dnUU798zNnZ2d@giganews.com> <87lffbbohr.fsf@izac.org>
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding 8bit
Organization !No_Organization!
Message-ID <5e2dndzT_a8HGDTCnZ2dnUU798zNnZ2d@giganews.com> (permalink)
Date Mon, 09 Nov 2020 12:08:26 -0600
Lines 94
X-Usenet-Provider http://www.giganews.com
X-Trace sv3-JE99Q/LsLVr9qOGz6mrp7H13YuRMctzY150P+xWwIHCSaJqAcL7bk+4MBvyrj49qUPbCb/O+54VNqVg!chUaDAPFe2SAbr/d8DaNHCW2Tnqgj6h6uEy61+YK7v/SYtaGtc0K5OJ+M2o871ZHDKnDhdOnm+G/
X-Complaints-To abuse@giganews.com
X-DMCA-Notifications http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Lines 92
X-Original-Bytes 3626
Xref csiph.com fr.comp.lang.python:3372

Show key headers only | View raw


Le dimanche 08 Novembre 2020 à 21:08 par Benoit Izac :
> Bonjour,
> 
> Le 08/11/2020 Í  18:47, vdperic a écrit dans le message
> 
> 
>> Je commence Í  m'intéresser Í  Python. Je suis
>> le livre Apprendre la
>> programmation par le jeu. Pourquoi ceci fonctionne
>> 
>> from tkinter import *
>> import random
>> 
>> def melangemot(mot) :
>> melange = mot
>> for i in range(len(mot)) :
>> a = random.randint(0,len(mot)-1)
>> b = random.randint(0,len(mot)-1)
>> new = ""
>> for j in range(len(melange)) :
>> if j==a :
>> new = new + melange[b]
>> elif j==b :
>> new = new + melange[a]
>> else :
>> new = new + melange[j]
>> melange = new
>> return melange
>> 
>> def verif():
>> if E.get().upper() == m :
>> L.config(text="Gagné !")
>> else :
>> B.config(text="Non, réessayer ?")
>> 
>> fen = Tk()
>> fen.geometry("200x100")
>> fen.title("Mots mélangés")
>> 
>> m="Maison"
>> 
>> 
>> L=Label(fen,text=melangemot(m),width )
>> L.place(x ,y)
>> E=Entry(fen,width$)
>> E.place(x ,y0)
>> B=Button(fen,text="Valider",font='arial 9',width ,command=verif)
>> B.place(x ,y`)
>> B.focus()
>> fen.mainloop()
>> 
>> 
> Pour moi, ça ne peut pas fonctionner : vu que tu compares
> une chaͮne que
> tu mets en majuscule Í  'Maison', personne ne gagnera
> jamais… Il faut un
> upper() (ou lower()) de chaque cÍ´té pour que ça
> fonctionne.
> 
>> mais quand je mets
>> m=input("Choisissez un mot:")
>> ça ne marche plus.
>> 
>> 
> Boule de cristal HS. Tu mets ça o͹ ? Qu'est ce
> qui ne marche pas ?
> 
>> Pouvez-vous m'expliquer ? Je vous en remercice
>> 
>> 
> input() attend quelque chose sur l'entrée standard ; en
> général le
> terminal. Donc si tu lances ça depuis autre chose qu'un terminal et que
> rien n'arrive sur l'entrée standard, ton programme reste bloqué
> après la
> création de la fenêtre. C'est peut-être ça
> «Â ne marche plus »Â ?
> 
> PS : il y a plus élégant pour mélanger ta
> chaÍ®ne de caractère :
> 
> def melanger(mot):
> return ''.join(random.sample(mot, len(mot)))
> 
> --
> Benoit Izac
En fait je vais réexpliquer:
Quand j'entre moi-même dans le programme le mot "Maison" (m="MAISON), ça
fonctionne bien !
Par contre quand je demande d'entrer un mot avec INPUT, ça ne marche plus. Le
programme reste bloqué et la fenêtre ne se crée pas.
C'est bizarre parce que si je demande print (m), le programme met bien le mot
choisi par l'utilisateur !

Merci déjà pour le mélange de caractères. C'est nettement plus court

Back to fr.comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Pourquoi ca ne marche pas vdperic <nospam_vdperic@yahoo.fr.invalid> - 2020-11-08 11:47 -0600
  Re: Pourquoi ca ne marche pas Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2020-11-08 21:08 +0100
    Re: Pourquoi ca ne marche pas vdperic <nospam_vdperic@yahoo.fr.invalid> - 2020-11-09 12:08 -0600
      Re: Pourquoi ca ne marche pas Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2020-11-09 19:58 +0100
        Re: Pourquoi ca ne marche pas vdperic <nospam_vdperic@yahoo.fr.invalid> - 2020-11-10 04:08 -0600
          Re: Pourquoi ca ne marche pas Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2020-11-10 13:34 +0100

csiph-web