How do I combine these with Pyscript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do I combine these with Pyscript?

i know only beginner level html and have only written a few python scripts go easy on me. Sample input would be GUARD1 1 OPEN also does the html code need a spot for output? https://code.sololearn.com/cT9Y981anJ5I/?ref=app https://code.sololearn.com/W73G2rjuBD3N/?ref=app https://code.sololearn.com/WhSLrYt1L705/?ref=app

7th Aug 2023, 10:51 AM
Travis Beard
Travis Beard - avatar
3 Answers
+ 2
You actually already figured out the solution in your previous question, maybe you just don't see it yet. You seem to have some sort of a game concept here. A game has a flow, a series of steps or 'events'. The event loop controls the duration of the game. In your code, this is an endless while loop: while True: You actually need to change this part. Remove the loop completely, and remove the input() statements. Instead you need to write a function (def) where you handle only a single event. The function has no parameters, because the actual arguments will be read from the html input elements. And it's up to you how you want to display the output. You can write it to the console with the print statement, or use a html element such as a div, where you either replace the text content or append to it every time when a new event occurs. You have already done this in your other question. Finally what you already discovered is you can put a pys-onClick attribute on your button which will trigger this function.
8th Aug 2023, 5:20 AM
Tibor Santa
Tibor Santa - avatar
0
I guess i dont know how to take multiple inputs except with multiple args? im not sure where to begin writing that function...Would you be kind enough to point me towards some information i could look at to work through it? I want to write it but not sure if i dont know or i put in too many hours yesterday. at one point i typed the actual word code instead of code i was so tired haha https://code.sololearn.com/WhSLrYt1L705/?ref=app
8th Aug 2023, 6:08 AM
Travis Beard
Travis Beard - avatar
0
Where im at. Trying to replace variables with html input https://code.sololearn.com/W16otZ0zBckI/?ref=app
10th Aug 2023, 10:45 AM
Travis Beard
Travis Beard - avatar