Dunce
@Dunce
Bio goes here.
when I run the following code:
import numpy as np
import pygame
surface = pygame.Surface((300, 300))
array = pygame.surfarray.array3d(surface)
for i
0
weekly-4weekly-4 challenge
21
4
0
Just give this repl the filepath to your code and it will leave many totally useful comments!
By default it only works with Python code, but it's eas
Python
Hello, I'm working on making a search engine, I already made a web crawler which stores the URLs it finds in Repl DB.
Now I'm wondering how I would e
Introduction
Hello, this is a game I made a while back. I didn't finish it, but I thought it seemed a shame not to post it, because it's one of my bes
Pygame
Introduction
the HTML `title` attribute allows you to add tooltips to your elements, these are great for accessibility, or just making your webpage mo
HTML, CSS, JS
Bookie0 Hmm I thought that attribute was called title? Tooltip would be something like this:
1_3gJ2VKho0yW4vEovAMtrjg
Whereas this is title:
Screen Shot 2021-06-10 at 11.04.25 AM2 years ago
This code:
print(sorted([3, 3, 3, 2, 2, 2, 1, 1, 1,]))
outputs: [1, 2, 3]
But I would like it to keep the duplicate values, that is to say it should o
Coder100 Use the sort method instead
https://www.freecodecamp.org/news/the-python-sort-list-array-method-ascending-and-descending-explained-with-examples/2 years ago
I know you can download a file onto a user's device, like this:
let file = new File(["Example"], "example.txt", {
type: "text/plain"
})
let url = UR
So this code:
myList = [[1, 2, 3], [1, 2, 3], [1, 2, 3]]
newList = [item for item in list]
is equivalent to:
myList = [[1, 2, 3], [1, 2, 3], [1, 2, 3]
IMayBeMe This is kind of cheap but it works:
import itertools
myList = [[1, 2, 3], [1, 2, 3], [1, 2, 3]]
newList = list(itertools.chain.from_iterable(myList))
Slightly less cheap way:
myList = [[1, 2, 3], [1, 2, 3], [1, 2, 3]]
newList = [i for j in myList for i in j]
2 years ago
Hello, how would I add server side code to a website? I already know a little bit of node.js. I just don't know how to actually add it to a website.
robowolf If you know python I would suggest using Flask. Here's a link to get you started.2 years ago
This repl uses the frequencies of the various letters' usage in everyday language to create a randomly generated word.
Press enter to generate another
Python
When trying to make a canvas full screen you might think you could just write a CSS rule to resize it, like so:
canvas {
width: 100%;
height: 100vh;
}
RixTheTyrunt You made a error! Look:
height 100vh;
while it needs to be like this:
height: 100vh;1 year ago
Coder100 pixel ratio is what you are looking for
https://stackoverflow.com/questions/15661339/how-do-i-fix-blurry-text-in-my-html5-canvas
you see, some computers have more pixels so you need to fix that2 years ago
Hello, this is a text editor I created. Your notes are saved in local storage, I think the rest is pretty self explanatory.
HTML, CSS, JS
How would I position an element from a spot other than it's center in CSS?
For example if I positioned an element something like this:
img {
position:
notGilbert Do you have any transform applied to the image, that may be causing the pivot to be moved to the center.
img {
position: absolute; /* not recommended for most cases */
top: 50%;
left: 50%;
transform: unset;
}
`2 years ago
Hello I would like to take the string I get from a textarea, then look for certain words in that string, then apply a style to them. How would I do th
Coder100 oh yeah btw
if you are thinking of making a code editor... don't do this
it'll cause more pain than anything, considering you could use something that replit uses, in half the time
https://microsoft.github.io/monaco-editor/
unless ur making a Microsoft word, you should probably reconsider2 years ago
EdwardBentler @Dunce
If I understand you correctly, I think I have an answer,
First, you'd have to get the string from the text area, so you would select the text area,
document.querySelector('.textArea')
Then you'd have to select the text inside,
document.querySelector('.textArea').innerHTML
That should give you a string with whatever is inside of the text area, you could save the string to a variable if you want, whatever you want to do you can. Next, there's a special function for finding certain words2 years ago
I get the error:
AttributeError: type object 'Image' has no attribute 'new'
When I run the code:
from PIL import Image
image = Image.new("RGB", (100,
SixBeeps Instead of
from PIL import Image
try
import PIL.Image
then use
image = PIL.Image.new("RGB", (100, 100))
`2 years ago
How would I make a one line while loop?
I know you can do
while True: print("Hello world!")
but then if I put anything before it, like
print("Start!")
So if I had a rotated sprite in pygame, and I wanted to move it in the direction it was facing, how would I do that?
I don't want the movement to have
notGilbert I'm not a pygame expert, but you can use trigonometry, and simple xy movement to move it in a direction.
from math import sin, cos
direction = 0 # in radians!!!
speed = 20
def move():
player.x += cos(direction) * speed
player.y += sin(direction) * speed
you might need to tweak it a little (change the signs) since it will assume the player is facing horizontally
2 years ago
How would I create an optional positional argument in python? All the instructions I've been able to find are unclear.
InvisibleOne something like this:
def banana(name, color='yellow'): # color will default to yellow if not argument is given
print("Nice " + name + " banana that is " + color)
banana("joey") # will print out the color as yellow
banana("bill", "green") # will print out the color as green
`2 years ago
Hello, I just learned about meta tags in HTML, and I would like to specifie that I'm the author of a webpage, with a link to my Replit profile page.
B
SixBeeps Meta tags do nothing but hold text. It does not hold any HTML data. You can put the link to your Replit account in there if you'd like, but the whole point of Meta information is to make it easier to find your webpage.2 years ago