473,396 Members | 2,011 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,396 software developers and data experts.

continue "not properly in loop"

hi guys! i'm successful in creating my first kbc game with one question with integers and strings as input!well i'm a strater and please help because i want to loop it with break if lose and continue with win after first question.simply i want to continue it and want to know how?please give me the modified script so i can move in my project!here's the script!pls help!


Expand|Select|Wrap|Line Numbers
  1.  
  2. question1 = "who was the first president of india?"
  3. option1 = "a.rajendraprasad"
  4. option2 = "b.sonia gandhi"
  5. option3 = "c.indira gandhi" 
  6. option4 = "d.jawaharlalnehru"
  7. print question1, option1,option2,option3,option4
  8.  
  9. first = raw_input("enter your answer!").lower()
  10. a = option1
  11. if first == 'a':
  12.         print 'you win!'
  13. else:
  14.     print 'you lose!'
  15.  
Attached Files
File Type: txt New Text Document (3).txt (362 Bytes, 636 views)
Jun 4 '11 #1
2 10504
dwblas
626 Expert 512MB
I would suggest a list of questions sent to a function. This is very basic so if you do not understand any of this check one of the online books, since it is impossible to guess how much Python you know,
Expand|Select|Wrap|Line Numbers
  1. def ask_question(question):
  2.     print "-"*30
  3.     print question[0], "\n"
  4.     for ctr in range(1, len(question)-1):
  5.         print ctr, question[ctr]
  6.     print
  7.     first = raw_input("enter your answer! ")
  8.     if first == str(question[-1]):
  9.         print 'you win!'
  10.         return True
  11.  
  12.     print 'you lose!'
  13.     return False
  14.  
  15.  
  16. q_list = [ ["who was the first president of india?",
  17.             "rajendraprasad", "sonia gandhi", "indira gandhi", 
  18.             "jawaharlalnehru", 1],
  19.            ["What is 3 + 2?", "23", "5", "32", "1", 2] ]
  20.  
  21. ctr = 0
  22. result = True
  23. while result:
  24.     result = ask_question(q_list[ctr])
  25.     ctr += 1 
Jun 4 '11 #2
thank you very much now i can complete my project at kbc game and i will upload it and give you a large credit!please me connected to help me in more projects!
Jun 5 '11 #3

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

Similar topics

4
by: db2group88 | last post by:
we are using db2 udb v8.2 on windows. all our tables are created with not logged initially property, So if i want to activate HADR (high availability disaster recovery) for the database, in...
1
by: deko | last post by:
This sub pulls Outlook Appointments into a table. The problem is I want to limit the import to Location = Boston I'm not sure how to code that into the For... To loop - As it is now, I get the...
9
by: Bob Alston | last post by:
I have a drop down combo box that gives the user to enter an item not in the list by adding it to the list. The list is a table. It works fine on Access2003 but fails on Access2002/XP. ON XP, it...
3
by: Mark | last post by:
Hello, Recently I have not been able to open an asp.net page in MDE's web from designer. I recieve the following error: "The file failed to load in the web from designer. Please correct the...
6
by: swartzbill2000 | last post by:
Hello, I have some downloaded source code on my machine that the .net framework thinks is "not fully trusted". How can I fix this? I assume I use the 'Microsoft .NET Framework 1.1 Configuration'...
6
by: John Pass | last post by:
What is the difference between a While and Do While/Loop repetition structure. If they is no difference (as it seems) why do both exist?
2
by: riceyeh | last post by:
Hi, What does <xsl:if test="not($values)"mean? What I do not understand is $values? Here, means array? And . = $value means current node is equal to the variable value? So the total meaning is...
2
by: deggler | last post by:
hi, i'd need to run a while ($row = mysql_fetch_array($result)) loop thru the whole table and then one more time. this last time the $row variable shouldn't get any values. i just need everything...
6
by: vanlanjl | last post by:
I cannot get the not in list event to work right. On my form I have a combo box named "cboChargeCode" I have a table named "tblChargeCode" I would like it so when you enter a value into the...
1
by: Todd Tichenor | last post by:
SELECT F.fname FROM Faculty F WHERE NOT EXISTS(SELECT DISTINCT C.room FROM Class C) EXCEPT (SELECT C2.room FROM Class C2 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.