Newbie wants help with a small code... :)

This is the place for queries that don't fit in any of the other categories.

Newbie wants help with a small code... :)

Postby rstattin » Tue Mar 25, 2014 2:47 pm

Hello! I'm totally new when we're speaking about programming. I want to learn more and I started with Python that I read should be the easiest one to start with.
I'm running some tutorials and now I want to make an own test-script. I have been written a little bit but now I have got a problem...

Look at the code under here:
Code: Select all
add_one = "k"

first_word = raw_input('Enter a word and hit "ENTER")
#In this example I write down "TEST" and hit "ENTER" and now the word "TEST" is stored in "first_word".

second_word = first_word + add_one
#After this, "Second_word" does now stores the word: "TESTk"

print second_word
#On the display or the cmd/terminal or whatever you use it will be this word as I said up there: "TESTk"

But now I want to make an other code. In this code I want to do almost the same thing but the complete opposite... I want to start the program and when it asks me to "Enter a word and hit "ENTER"" I will write down the word "TESTk" and after I hit ENTER I want to see what word it was from the beginning.

Sorry for bad description...

Hope anyone can give me a code or help me do this! :)
Posts: 1
Joined: Tue Mar 25, 2014 2:33 pm

Re: Newbie wants help with a small code... :)

Postby stranac » Tue Mar 25, 2014 3:09 pm

So you just want the word without the last letter?
Code: Select all
>>> 'TESTk'[:-1]
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
Posts: 1093
Joined: Thu Feb 07, 2013 3:42 pm

Return to General Coding Help

Who is online

Users browsing this forum: micseydel and 3 guests