+ 2

Can someone please help me with this code?

The idea is to create an infinite loop until the output equals the input. Can someone please tell how to make it break? https://code.sololearn.com/cY5NLPL05XzZ/?ref=app I edited it

28th Apr 2022, 12:59 AM
Ava Alford
19 Answers
+ 1
This is basically your code corrected and works for words as well. and you could edit it a bit to work for anything. I tried to keep as much as possible from your original code and added few things for fun. https://code.sololearn.com/cz6LmvoliAEH/?ref=app
29th Apr 2022, 8:38 PM
Mohamad Aljammal
Mohamad Aljammal - avatar
+ 1
Np. Your Idea was nice btw. In general try to structure the shit out of your code in your mind, I noticed that you had the idea and the syntax right but your structure was a little bit off.
29th Apr 2022, 8:52 PM
Mohamad Aljammal
Mohamad Aljammal - avatar
+ 1
I will add some comments and recomment the code. Then you can ask again after going through it.
29th Apr 2022, 8:59 PM
Mohamad Aljammal
Mohamad Aljammal - avatar
0
I don't understand what this code is supposed to do ! Is it supposed to keep choosing letters at random until it equals the input? Like bruteforcing?
28th Apr 2022, 5:26 AM
FeDi BbM
FeDi BbM - avatar
28th Apr 2022, 12:22 PM
Ava Alford
0
Ava Alford and why do use files for that?
28th Apr 2022, 12:33 PM
FeDi BbM
FeDi BbM - avatar
0
FeDi BbM the idea is to write to the file the random letter choice. Though I suppose you could do it another way. That opens up other possibilities I might try
28th Apr 2022, 1:06 PM
Ava Alford
0
FeDi BbM can you please look at my new code? Can you please tell me what would be a good way to do this or what I can change? I'm sure it's a lot
28th Apr 2022, 1:19 PM
Ava Alford
29th Apr 2022, 10:30 AM
Bob_Li
Bob_Li - avatar
0
Mohamad Aljammal thank you so much. That was very helpful
29th Apr 2022, 8:44 PM
Ava Alford
0
Mohamad Aljammal can you explain if control: continue break for me please?
29th Apr 2022, 8:51 PM
Ava Alford
0
Mohamad Aljammal I don't completely understand the control statements.
29th Apr 2022, 8:54 PM
Ava Alford
0
Feel free to ask. I might modify some things further so I might post it here again. https://code.sololearn.com/cz6LmvoliAEH/?ref=app
29th Apr 2022, 9:13 PM
Mohamad Aljammal
Mohamad Aljammal - avatar
0
Mohamad Aljammal thank you.
29th Apr 2022, 11:57 PM
Ava Alford
0
Mohamad Aljammal I have a few questions I left in the comments. https://code.sololearn.com/c5o2aJjQdvzQ/?ref=app
30th Apr 2022, 1:15 AM
Ava Alford
0
Mohamad Aljammal I have another code that does something similar. Can you explain how to make it work to where it never prints no output? https://code.sololearn.com/co9hZQlW7EnT/?ref=app
30th Apr 2022, 2:09 AM
Ava Alford
0
Each time you write a character to the file You are appending it to a new line. So if a user enters anything other than a single letter, you wont ever find a match
30th Apr 2022, 4:20 AM
Raul Ramirez
Raul Ramirez - avatar
0
Actually you arent even appending it to a new line, but instead just overwritting the file Aka file only ever contains one letter
30th Apr 2022, 4:38 AM
Raul Ramirez
Raul Ramirez - avatar
30th Apr 2022, 4:42 AM
Raul Ramirez
Raul Ramirez - avatar