Allen Ding

@UniqueOstrich18 (290)
Check out my pinned repls!
Web browser made with PyQt5
posted to Share by UniqueOstrich18

@jeweledfox Sorry, I can't. Repl.it doesnt support the shift key for some reason.

how do you skip this?!?!?!??!??!
posted to Ask

Replace line 16 with:

  if generates == "far" or generates == "sort of far" or generates == "close": generate = input("press g to generate")

And replace line 37 with:

  if generates == "super far" or generates == "sort of super far" or generates == "far": generate = input("press g to generate")

If this was helpful, please mark this as the answer.

Also, please check out this (https://repl.it/talk/share/2048-In-Python/31140). I spent a ton of time making it.

What does Repl.it: Package operation failed mean?
posted to Ask by Csilarion

The package installation is failing because the package you are trying to install isn't supported by repl.it.

If this was helpful, please mark is as the answer.

Space Race Game
posted to Share by blakethegreat

@MeharSinghSingh no you are

Please help me debug!
posted to Ask

On line 60, change it to:

  (''.join(choice((str.upper, str.lower))(c) for c in sentence3))

Change line 56 to:

"""

Change line 61 to:

"""

Change line 41 to:

  fortune1 = ''.join(choice((str.upper, str.lower))(c) for c in sentence1)

It should work after you make those changes.

The fixed program is at https://repl.it/@UniqueOstrich18/Password-writer, if you just want to copy the code.

There are multiple fixes you need to make because I discovered more issues.

If this was helpful, please mark it as the answer.

How to learn codes faster
posted to Ask by CHARLESHARPER

Look in the learn section.

Crash: repl process died unexpectedly: signal: killed
posted to Ask by DavidMarr

This happens when the system runs out of memory, and has to kill the program. Consider running it on your own computer, as repl.it only gives you 200MB of RAM.

Stopwatch Trouble plz help
posted to Ask by GabrielDixon

Your issue is that you read the hour value from where the second value is stored, and vice versa. Change lines 7-14 to this:

with open("save.txt") as x:
  for i, line in enumerate(x):
    if i==0:
      h=int(line)
    if i==1:
      m=int(line)
    if i==2:
      s=int(line)

If this was helpful please mark it as the answer

How do you switch values
posted to Ask by EmmaPitner

As seen on https://stackoverflow.com/questions/2493920/how-to-switch-position-of-two-items-in-a-python-list, you can just do this:

thing[i], thing[j] = thing[j], thing[i]

Where i is the index of your first item, and j is the index of your second item.

If this was helpful, please mark it as the answer!

I need help with this code
posted to Ask by LOLLIPOP06

@LOLLIPOP06 You can just put print("The computer chose: " + computer) before the if statements:

import random
computer = random.choice(["rock","paper","scissors"])value in the list
human_choice = input("choose rock, paper, or scissors: ")

print("The computer chose: " + computer) #<--- Add this code
if human_choice == 'rock'  and computer == 'rock':
    print("This is draw!")
if human_choice == 'paper'  and computer == 'paper':
    print("This is draw!")
if human_choice == 'scissors'  and computer == 'scissors':
    print("This is draw!")
if human_choice == 'rock'  and computer == 'paper':
    print("The computer won!")
if human_choice == 'rock'  and computer =='scissors':
    print("You won!")
if human_choice == 'paper'  and computer =='rock':
    print("You won!")
if human_choice == 'paper'  and computer == 'scissors':
    print("The computer won!")
if human_choice == 'scissors'  and computer == 'rock':
    print("The computer won!")
if human_choice == "scissors"  and computer == 'paper':
    print("You won!")
if human_choice != "paper"  and human_choice != "scissors"  and human_choice != "rock":
    print("You can only choose something from : ROCK PAPER OR SCISSORS")
I need help with this code
posted to Ask by LOLLIPOP06

Your issue was that putting computer = "rock" or "paper" or "scissors" didn't actually do anything. You have to put computer = random.choice(["rock","paper","scissors"]) Also, input() has to be assigned to a variable.

import random
computer = random.choice(["rock","paper","scissors"]) #random.choice takes in a list, then outputs a random value in the list
human_choice = input("choose rock, paper, or scissors: ") #you need to assign input() to a varible
#Your code below this works fine

if human_choice == 'rock'  and computer == 'rock':
    print("This is draw!")
if human_choice == 'paper'  and computer == 'paper':
    print("This is draw!")
if human_choice == 'scissors'  and computer == 'scissors':
    print("This is draw!")
if human_choice == 'rock'  and computer == 'paper':
    print("The computer won!")
if human_choice == 'rock'  and computer =='scissors':
    print("You won!")
if human_choice == 'paper'  and computer =='rock':
    print("You won!")
if human_choice == 'paper'  and computer == 'scissors':
    print("The computer won!")
if human_choice == 'scissors'  and computer == 'rock':
    print("The computer won!")
if human_choice == "scissors"  and computer == 'paper':
    print("You won!")
if human_choice != "paper"  and human_choice != "scissors"  and human_choice != "rock":
    print("You can only choose something from : ROCK PAPER OR SCISSORS")

If this comment was helpful, please mark it as the answer.

WHY?
posted to Ask by zhidao

Yeah, that happened to me. They just fork my repls and remove the parts crediting me.

Web browser made with PyQt5
posted to Share by UniqueOstrich18

@Nathankang77 Also can you upvote this post?

Wack a Mole
posted to Share by AndrewZhao1

This is great

a clock
posted to Share by EricXie1

its a clock

       .-.-.
  ((  (__I__)  ))
    .'_....._'.
   / / .12 . \ \
  | | '  |  ' | |
  | | 9  /  3 | |
   \ \ '.6.' / /
    '.`-...-'.'
     /'-- --'\
    `"""""""""`

Clock ascii art from https://www.asciiart.eu/electronics/clocks

Import Variables from a file that isn't .py
posted to Ask by earwarmers

The easiest way to store data in a file is using the pickle module. The pickle module stores, or "pickles," varibles and data in a file.

This is an example from the Python wiki:

# Save a dictionary into a pickle file.
import pickle

favorite_color = { "lion": "yellow", "kitty": "red" }

pickle.dump( favorite_color, open( "save.p", "wb" ) )
# Load the dictionary back from the pickle file.
import pickle

favorite_color = pickle.load( open( "save.p", "rb" ) )
# favorite_color is now { "lion": "yellow", "kitty": "red" }

More information can be found at https://www.datacamp.com/community/tutorials/pickle-python-tutorial and https://www.geeksforgeeks.org/understanding-python-pickling-example/.

If this was helpful, please mark it as the answer.

Hyperlink, hello?
posted to Ask by Axrevyn

@Axrevyn PyQt5 is a python module for the creation of guis.

Hyperlink, hello?
posted to Ask by Axrevyn

It's just a repl.it thing. Same thing happened to PyQt5 a few months ago.

If this was helpful, please mark it as the answer.

Does anyone have any project ideas?
posted to Ask by HerculukeZeEpic

Number guessing game?

How do I make the code stop after three guesses
posted to Ask by niteeshtapre

Here's the fixed code:

import random
guesses = 0

while guesses<3:
  value = random.randint(1, 10)
  number_1 = input("\nEnter your guess (1-10): ")
  if number_1.isdigit():
    number_1 = int(number_1)
    if number_1 == value:
      print("You guessed the number!\nThe number generated was "+str(value))
      break
    else:
      print("Wrong!\nThe number generated was "+str(value))
  else:
    print("Wrong!\nThe number generated was "+str(value))
  guesses += 1

If this was helpful, please mark it as the answer.

Can anyone tell me how to make everything after line 9 shorter?
posted to Ask by AlexanderLuna

I've shortened the program to 17 lines:

print("Welcome to guess the number.")
print("There will be three rounds.")
print("This is round 1.")
print("(If your guess is incorrect run the code again.)")
print("I'm thinking of a number 1 through 10.")
def make_guess(number):
  guess = int(input("Your guess: "))
  if number == guess:
    print("Correct!")
  else:
    print("Incorrect...")
numbers = [7,4,6]
counter = 0
for number in numbers:
  counter = counter + 1
  print("Round "+ str(counter))
  make_guess(number)

The output is exactly the same. The make_guess function takes the argument number, which will be used as the answer, and asks the user to guess. Then if the guess is equal to the answer, it prints "Correct!" If the guess is not equal to the answer, it prints "Incorrect..." The for loop at the end is so that the program can cycle through all of the answers in the list of answers. The counter variable is so that the program can keep track of what round it is.

Sorry if the text above is a little hard to understand.

If this was helpful, please mark it as the answer.

I am making a pig Latin translator but for it doesn't work like I want it to.
posted to Ask by AhmadShaheerSha

Change line 23 and 24 to:

main()

There is no need for the if statement because the program is supposed to run the main() function anyways.

If this was helpful, please mark it as the answer.

Please help me debug!
posted to Ask

@Codemonkey51 Did you actually test that? If you just add ) to the end of line 60, it won't work because there are more issues.

how do we print an apostrophe?
posted to Ask by penguin129

You can use \ before the apostrophe, or use double quotes (") to enclose the string that you want to print.

Backslash method:

print('\'')

Double quotes method:

print("'")

If this was helpful, please mark it as the answer.

Typewriter Python
posted to Ask by ShadedFlame

Here is a simple typewriter program, made in python 3:

import readchar,os
characters = []
def refresh():
  os.system("clear")
  string = ""
  string = string.join(characters)
  print(string)
while True:
  char = readchar.readkey()
  if char == readchar.key.BACKSPACE:
    try:
      del characters[len(characters)-1]
    except:
      pass
  elif char == readchar.key.ENTER:
    characters.append("\n")
  else:
    characters.append(char)
  refresh()

Output:

You can run it at: https://repl.it/@UniqueOstrich18/Typewriter

If this was helpful, please mark it as the answer.

python turtle taking "if" as a ParseError: bad input. why?
posted to Ask by CAVOU

Change:

if elephant_weight > ant_weight

To:

if elephant_weight > ant_weight:

If statements need to have : at the end of them.

If this was helpful, please mark it as the answer.

how do i stop it from counting once i got it to 500?
posted to Ask by PercyPetrou

Put an if statement where, if the counter is 501, then break out of the loop:

counter = 1

counter = int(input("what number do u want to count up from"))
while counter >=1:
  print(counter)
  counter = counter + 1
  if counter == 501:
    break

If this was helpful, please mark it as the answer.

Also, could you check out https://repl.it/talk/share/2048-In-Python/31140? I spent a lot of time making it.

how to fix zerodivisionerror
posted to Ask by BunchOfOf

You can put the part where you divide the numbers in a try: except: block, so that when an error occurs, you can print a custom error. Also, you can half the program's length by using or in your if statements. The modified code is below.

from math import *

l = "\n"

while (1 == 1):
  num1 = input("enter a number :")
  vary = input("what you want to do with the no. :")
  num2 = input("enter the second number: ")
  
  while (1 == 1):
    if vary == "+" or vary == "plus":
      result = float(num1) + float(num2)
      print(str(result) + str(l))
      break
    elif vary == "-" or vary == "minus":
      result = float(num1) - float(num2)
      print(str(result) + str(l))
      break
    elif vary == "*" or vary == "multiply" or vary == "x" or vary == "X":
      result = float(num1) * float(num2)
      print(str(result) + str(l))
      break
    elif vary == "/" or vary == "divide":
      try:
        result = float(num1)/float(num2) #if this part errors
        print(str(result) + str(l))
      except:
        print("You can't divide by zero!") #then this part runs
      break
    elif vary == "power" or vary == "to the power" or vary == "^":
      result = float(num1) ** float(num2)
      print(str(result) + str(l))
      break
    else:
      print("what you want to do with the no.s is not recoganized as an expression" + str(l))
      break

If this was helpful, please mark it as the answer.

Also, could you check this out (https://repl.it/talk/share/2048-In-Python/31140)? I spent a lot of time working on it.

how to share on gmail
posted to Ask by slynchtcssh

You can just email them the link.