0

My code, wat.txt contains a list of why I love her and This code isn't looping how I wanted. Originally I had.. Can someone direct me toward how I should fix this loop and keep getting sentences. I think its just the loops fault. I havn't programmed in a while, until today. :P thank you!(P.S. Its for my girlfriend)

This is the Original loop

while k:
    print("~ I love "+sen)
    wat=raw_input("")
    l.remove(sen)

    if wat=="Another" or "another" or "more":
        r=random.randint(1,n)-1
        sen=l[r-1]
        print("~ I love "+sen)
        wat=input("")
    if n <= 0:
        k=False
    else:
        k=False

2nd Attempt Not working Either

#! /usr/bin/env python
# -*- coding: utf-8 -*- 


l=[]
output=open('C:/Users/David/Downloads/files/wat.txt','r')

for line in output:
    l.append(line)


import random
n=len(l)
r=random.randint(1,n)-1
sen=l[r-1]
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("Type 'Quit' To Leave or 'Another' to see another reason why I love you")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  \n\n")
k=True
while k:
    print("~ I love "+sen)
    wat=raw_input("")
    l.remove(sen)

    if wat=="Another" or "another" or "more":
        r=random.randint(1,n)-1
        sen=l[r-1]

    if n <= 0:
        k=False
    else:
        k=False
David
  • 71
  • 8

0 Answers0