help

Status
Not open for further replies.
lol it is pretty cool. i got the idea from another snippet that i saw that was kinda like it and i modified it to what i knew and changed some stuff. and i came up with a simple one that scrambled the word "dictionary" it has to do with strings and assigning the order of the letteres differently by the different numbers like 0 is the first letter in a string. so you would just mix up the numbers in the string like

aStr= "to"

astr[0]+astr[1]

that would leave it as to

but change the 1 and the 0 so the 1 is first and you get

ot

and its just doing that and assigning it a variable and prompt for user input and if it was right or wrong and how many tries. thats what it does but many times over for different words.

note: you will have to manually scramble it i haven't figured out a randomization scramble yet.
 
that is pretty cool, it seems like alot of code for just a scrambling program, how long did it take u.

Edit: i am looking at it, i think i could edit a bit but nothin that would really change it, i havn't learned anything about user input yet so hopefully i will soon.
 
yea this is just what one scrambled word looks like

Code:
number = aStr = "dictionary"
answer = ''
print'Descramble this word!!'
print aStr[3] + aStr[6] + aStr[1] + aStr[5] + aStr[0] + aStr[9] + aStr[2] + aStr[8] + aStr[4] + aStr[7]
attempts = 0
while answer != number:
    answer = raw_input( '?' )
    attempts = attempts + 1
    if( answer > number ):
            print 'Try Again'
    elif( answer < number ):
          print 'Wrong'
    elif( answer == number ):
        print 'you got it rights in %i tries!' %(attempts)


just to make it simpler i just cut it down to one so you can look at it and understand the little pieces of it.

trust me it will takes some time this code took me about 2 days to figure out just that one little bit. but after i got that all i had to do was repeat it and switch the numbers of the strings for the different words and give them different variable names.
 
by what u just told me about scrambling the letter i was able to do this:

lefe="stealth"
print lefe[0] + lefe[3] + lefe[1] + lefe[2] + lefe[4] + lefe[6] + lefe[5]

it just scrambles the letter though (no input) but u know that, im gona look at ur code for a few mins to see if i can figure it out.
 
yea and when you get into doing the bigger codes and pasting them here in the forums be sure to use the code tags like
Code:
 and the corosponding end

im here to help you if you come across problems. :)
 
man, i have been trying to figure it out but im totally lost, im gona try to get a couple more lesson done to night, maybe that will help. i tryed just changing the word and the word scrabling stuff in ur code but it didn't work, there was a synax error. im guessing python can't be used to make programs (when i say programs i mean something that u start and its not in the cmd.

EDIT: what do u mean by code tags?
 
na. say you have 14 letters in a word you'd only have 14 astr[#] of those and each would have a number. and you need to keep the variables te same like when you specifie what the string is also called so you can keep that for comparison to the user's input. see where number = astr ba bla bla bla yo uget it
that means that that word is also stored in the variable number so yo ucan use that for comparison to their answer and its essential you keep that variable the same. look for more times i use number in that code and you'll see the pattern.

post what you have here in code tags.
 
Code:
lefe="stealth"
answer = ''
print 'descramble this word'
print lefe[0] + lefe[3] + lefe[1] + lefe[2] + lefe[4] + lefe[6] + lefe[5]
attemps = 0
while answer !=number:
answer = raw_input( '?' )
attempts = attempts + 1
if( answer > number ):
print 'try again'
elif( answer < number ):
print 'wronge'
elif( answer == number ):
print 'you got it right!!' %(attempts)

im not sure really what ur talking about. that all i have and o took most of it from ur code.
 
okay i see 2 things wrong here. one you dont have number specified so change the first line to be

number = lefe = "stealth"

and problem 2 is that when you put down answer you need to leave a space so its like this

answer = ' '

edit: 3 things now

at the end you need to have the i% so change the bottom line to be

print ' you got it right!! in %i tries! ' %(attempts)
 
it still didn't work. im kinda getting discouraged because in the tuturial it doesn't explain lists very good and i don't get them, do u know of any other tuturials that might be esier to understand.

EDIT: i found a tutorial that explains lists well and inputafter u write the program, im gona try to write something, then i'll post it
EDIT: well i kinda stoll someones idea but this is it, extreamily simple compared to urs but it a step forward for me:
print "Halt!"
s = raw_input("Who Goes there? ")
print "You may pass,",s
 
Status
Not open for further replies.
Back
Top Bottom