#๐Ÿ”’ my work

40 messages ยท Page 1 of 1 (latest)

deft vale
#

my python program is not working

supple crystalBOT
#

@deft vale

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

deft vale
#

import read

loop=True

while loop==True:
print("1. rent.")
print("2. return")
print("3.exit")
user_input = int(input("Enter your choice"))

if user_input==1:
    L_data=read.land()
    L_ids=list(L_data.keys())

    name=input(" Enter your name: ")
    phone_number=input(" Enter your contact number : ")

    land_id = input(" Enter the land_id ")

    while L_ids not in L_ids:
        print( "invalid landid")
        L_id = input(" Enter the land ID ")

    user_month = int(input(" Enter the month "))

    selected_item=L_data[L_id]
    selected_item[4]="Not Available"
    
    break
elif user_input==2:
    print("")
    break
elif user_input==3:
    loop=False
supple crystalBOT
#

Hey @deft vale!

It looks like you're trying to paste code into this channel.

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
deft vale
#
import read

loop=True

while loop==True:
    print("1. rent.")
    print("2. return")
    print("3.exit")
    user_input = int(input("Enter your choice"))
    
    if user_input==1:
        L_data=read.land()
        L_ids=list(L_data.keys())

        name=input(" Enter your name: ")
        phone_number=input(" Enter your contact number : ")

        land_id = input(" Enter the land_id ")

        while L_ids not in L_ids:
            print( "invalid landid")
            L_id = input(" Enter the land ID ")

        user_month = int(input(" Enter the month "))

        selected_item=L_data[L_id]
        selected_item[4]="Not Available"
        
        break
    elif user_input==2:
        print("")
        break
    elif user_input==3:
        loop=False                                       
                                    
   
#

'''py

#
def land():
    d={}
    f=open("land.txt","r")
    lines=f.readlines()
    
    for  line in lines:
        l=line.replace("/n","").split(",")
        key=l[0]
        value=[]
        for i in range(1,len(l)):
            value.append(l[i])
        d[key]=value

    f.close()
    return d
def land2():
    f=open("land.txt","r")
    lines=f.readlines()
    for line in lines:
        d=line
        print(d)
        
    f.close()
#

its not runing

wild olive
#

Is it jogging instead of running?

deft vale
#

it says invalid land to all

wild olive
#
land_id = input(" Enter the land_id ")
    while L_ids not in L_ids:
            print( "invalid landid")
            L_id = input(" Enter the land ID ")
#

What do you expect this to do?

deft vale
#

i want it to show not available if its not available and available if its avaialable how do i do that?

wild olive
#

Will L_ids ever not be in L_ids?

deft vale
#

no

wild olive
#

So; doesn't that indicate you have a mistake in that line?

deft vale
#

yes

wild olive
#

So what should you change it to?

deft vale
#

L_id?

wild olive
#

Sure that's a possibility. Perhaps it would help if I pointed out your second mistake

#

land_id and L_id shouldn't be different names here

deft vale
#

oh

wild olive
#

Either land_id should be L_id or L_id should be land_id. Choose one

deft vale
#

land_id = input(" Enter the land_id ")

#

in this line

wild olive
#

Yeah.. because it doesn't make sense to populate the name land_id and then test against L_id, right?

deft vale
#

yeah

#

thanks

wild olive
#

And then whichever you choose goes into the while statement

deft vale
#

mmhmm

#

how do i make it that if in the text file its not available then it shows not available when i give the number in the program

#

@wild olive

wild olive
#

I guess your number is stored as a string

deft vale
#

how to change

#

@wild olive

supple crystalBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.