Disclaimer: I am not looking for a full answer to this lab, only hints. I know people get frustrated when others ask to do their homework for them. ;P
Hey guys - first post here, although I have used this website many times to assist me with my Programming classes. I am in an entry level class, so this isn't anything too complicated, I could just use a hint to push me in the right direction.
1. Gets a string from a user.
2. Creates a new string which consists of the characters from the input string, with an asterisk (*) after each character. That is, if the input string was “Hello”, the new string would be “H*e*l*l*o*”. Hint: Think about string concatenation and accumulators. Recall how numeric counters and accumulators work with a loop and extend this to string concatenation.
3. Creates another new string by reversing the characters in the input string using a for loop. That is, if the input string was “Hello”, this new string would be “olleH”. Hint: Remember that string concatenation is not commutative.
4. Prints both new strings, along with appropriate literals.
This is the lab directions given to use by the Professor. I ams struggling a little bit on strings.
This is what I have so far:
inString = raw_input("Please enter a string") myString = "" for ch in inString: myString = myString + ch print myString
Of course, this code just prints the data that the user entered. Any hints to put me in the right direction would be very much appreciated.
And just an FYI: The Professor said the code could be done in very few lines (15 or less) so keep that in mind. Thanks in advance everyone.
Edited by Narue: Added code tags