Simple Programming Codes - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Simple Programming Codes (828 Views)
| Simple Programming Codes by ABCthingx(op): 8:22pm On Jun 03, 2022*. Modified: 10:19pm On Jun 03, 2022 |
1. Reverse A String python #Reverse a String – Enter a string and the program will reverse it and print it out' print ("____PROGRAM TO REVERSE A TEXT____ " ![]() print('_____type bye to quit the program_____') print ("____Write something then hit 'Enter'____" ![]() text = '' #just a declaration while text != "bye": text = input() x = len(text) for i in text: x -= 1 print(text[x], end='') print()
|
| Re: Simple Programming Codes by airsaylongcome: 9:24pm On Jun 03, 2022 |
You have imported the std namespace so no need for std::cout again. cout, cin You code isn't checking for edge cases such as when user just hits enter without any input. In a case like this your C++ code will output noitaralceD. I would initialize text with a blank string and check to ensure that user actually types an input. |
| Re: Simple Programming Codes by ABCthingx(op): 10:20pm On Jun 03, 2022 |
| Re: Simple Programming Codes by ABCthingx(op): 10:24pm On Jun 03, 2022*. Modified: 10:40pm On Jun 03, 2022 |
airsaylongcome:Thanks i've modified https://zerobin.net/?e396809972bf514e#tjf87uSWk7S0cTyGzhr72Qre1ofyLqb+sFpDJcoaGqk=
|
| Re: Simple Programming Codes by airsaylongcome: 11:15pm On Jun 03, 2022 |
ABCthingx:Did you run the new code you entered? The if statement for "You must enter a text sir" If you run it without entering text, that If just displays your prompt but does not stop the rest of the program from running |
| Re: Simple Programming Codes by Deicide: 9:08pm On Jun 04, 2022 |
Do not reinvent the wheel. Anyways write a programme that reverse ever word in the string. So "He is a boy" becomes "eH so a yob" |
| Re: Simple Programming Codes by Emmyxclusive: 6:06am On Jun 07, 2022 |
ABCthingx:in the python code what happens if a user enter a text in upper case or even combination of both? I think using the lower method on the text input is good |
Can You Write Codes With A Tablet Instead Of A Laptop? • Short Project: Arduino Uno Project (programming Codes) • Need Help With My Codes. • 2 • 3 • 4
Sport Prediction API • Helpppppppppppp! Asp.net Code Issue • Hospital Management System Needed
