repl.it
@BenOfWillis/

writing to file

Python

No description

fork
loading
Files
  • main.py
  • Text.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
pupils=["Ben","Jess","Jack","Emily","Daisy","Jacob"]
print("")
pupils.sort()
for i in range (len(pupils)):
  print (pupils[i].title())
  print ("")

#searchTerm=(input("What are you looking for? ")).title()
#Found=False
#for i in range (len(pupils)):
#  if searchTerm == pupils[i]:
#    print ("Your term is item:")
#    print (i+1)
#    Found=True
#if Found==False:
#  print ("NO")

if input("DO FIRST THING? ") == "yes":


  print("Input - to enter remove mode")
  print("Input + to enter add mode")
  print("Input stop to stop")

  print ("")
  stopped=False
  Mode="+"

  while stopped==False:

    if Mode=="+":
      Thing = (input("Add item: ")).title()
    if Mode=="-":
      Thing = (input("Remove item: ")).title()

    if Thing=="+":
      Mode="+"
    if Thing=="-":
      Mode="-"

    if Thing != "Stop":
      if (Mode == "+") and Thing != "+":
        pupils.append(Thing)
        print (pupils)
      if (Mode == "-") and Thing != "-":
        pupils.remove(Thing)
        print (pupils)
    else:
      print (pupils)
      stopped = True

import random
import time


while True:

  numbers=[]
  for i in range(100):
    numbers.append(random.randint(0,100))

  print ("The highest was:",max(numbers))
  a=0
  for i in range (len(numbers)):
    a=a+numbers[i]
  print ("Average is:",a)
  time.sleep(1)
Fetching token
?