473,411 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

How to name any elements of a list

Hi, I have some problem with my code:

Expand|Select|Wrap|Line Numbers
  1. from time import*
  2. from turtle import*
  3.  
  4.  
  5. mot = input("Quel est votre mot?")
  6. longueurMot = len(mot)
  7. lettre = list(mot)
  8.  
  9. a = 0
  10. b = -1
  11. while a != longueurMot:
  12.     a = a +1
  13.     b = b +1
  14.     down()
  15.     forward(100)
  16.     left(90)
  17.     forward(50)
  18.     left(90)
  19.     forward(100)
  20.     left(90)
  21.     forward(50)
  22.     left(90)
  23.     up()
  24.     forward(50)
  25.     left(90)
  26.     forward(25)
  27.     write(lettre[b])
  28.     left(180)
  29.     forward(25)
  30.     left(90)
  31.     forward(150)
  32. lettreEntrée = input("Entrez une lettre svp.")
  33. while lettreEntrée != lettre[]:
  34.     print("Cette lettre ne fait pas partie du mot. Réessayez.")
  35.     lettreEntrée = input("Entrez une lettre svp.")
  36.     if lettreEntrée == lettre[]:
  37.         break
  38.  
When I ask to write a letter, I want to know if this letter is in my list. If not, I want to print : This letter is not in my word.

P.S.: I am french so sorry if you don't understand some words :)
Nov 9 '14 #1
2 1220
bvdet
2,851 Expert Mod 2GB
The "in" operator can be applied to a sequence such as a string or list.
Expand|Select|Wrap|Line Numbers
  1. >>> word = "example"
  2. >>> if "e" in word:
  3. ...     print "This letter is in my word"
  4. ... else:
  5. ...     print "This letter is not in my word"
  6. ...     
  7. This letter is in my word
  8. >>> 
Nov 10 '14 #2
Thank you very much :D
Nov 10 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Alex Sab | last post by:
Hi, I am having trouble describing in a schema that elements can be mandatory in one part and not mandatory in another part of the xml document. Here is a sample xml file <Model:Templates>...
22
by: Luke | last post by:
Elements with name attribute: form, input, textarea, a, frame, iframe, button, select, map, meta, applet, object, param, img (if you know more reply...) Methods of addresing html elements:...
7
by: Evangelista Sami | last post by:
Hi all i have implemented a list type as an array of pointer like this typedef struct { int nb_elements; void **elements; } list; to avoid having a pointer for each element as it is done...
4
by: juli jul | last post by:
Hello, How can I pass over all the elements that are in the first column of listview? I need to do it in a loop and to present each cell value,how? Thank you! *** Sent via Developersdex...
13
by: Leszek Taratuta | last post by:
Hello, I have several drop-down lists on my ASP.NET page. I need to keep data sources of these lists in Session State. What would be the most effective method to serialize this kind of data...
1
by: Gi | last post by:
Hi, Can anyone tell me you can I transform this kind of XML: <Cont ID='faqs'> <Conts ID=''> <Elements> <Data></Data> <Pergunta></Pergunta> <Resposta></Resposta> </Elements>
11
by: shankwheat | last post by:
I have a function which passes text from txtdebt to debtsbox which works fine. However, I want to add code which examines the value of debtsbox and if any of the values the user entered contain the...
2
by: Kevin Walzer | last post by:
I'm trying to avoid a *lot* of typing in my Tkinter application by associating image names with items in a list. Here is my sample list: self.catlist = I've also already created a bunch of...
0
by: Alan Johnson | last post by:
I am trying to specify that an element may contain simple content (an integer), or complex content (a sequence of two other elements), but not both. The listMember element in the following XML...
2
by: aberry | last post by:
Hi all, In my script , I need to get name of list Im using eg. sat I have following list ... mca = Now I want to get name of the list i.e. just 'mca'. Do anyone know any method/attribute...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.