#๐ my work
40 messages ยท Page 1 of 1 (latest)
@deft vale
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.
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
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.
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
Is it jogging instead of running?
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?
i want it to show not available if its not available and available if its avaialable how do i do that?
Will L_ids ever not be in L_ids?
no
So; doesn't that indicate you have a mistake in that line?
yes
So what should you change it to?
L_id?
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
oh
Either land_id should be L_id or L_id should be land_id. Choose one
Yeah.. because it doesn't make sense to populate the name land_id and then test against L_id, right?
And then whichever you choose goes into the while statement
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
I guess your number is stored as a string
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.