28 August 2025
Replymessage unavailable
Trying to create a type generic which will allow or restrict from specifying only one key (or no keys at all). UPD1: shown keys are just specific for target task. The question is about if it's "legal" to pass real-values in generic like in C++ templates. True or False for T. UPD2: The answer is no, it just doesn't work like that cause the Template parameter alwas has TypeVar type
•𝕋𝕚𝕥𝕒𝕟𝕏⦅卐⦆•elif user == "game".:
consol = random.randint(1, 3)
gus = input("hadst:")
if gus == (consol):
print (" afrin dorost bod !!")
else:
print (f" galat bod ! ): add man {consol} bod!")
what is worng??
Why you say it is wrong?
What do you expect that code to do?
Charly RománWhy you say it is wrong?
What do you expect that code to do?
Why is it like this?
I wrote elif user == "game".: but it gives me a syntax error.
And also, when I compare input() with random.randint, it never matches. Why does that happen?
•𝕋𝕚𝕥𝕒𝕟𝕏⦅卐⦆•Why is it like this?
I wrote elif user == "game".: but it gives me a syntax error.
And also, when I compare input() with random.randint, it never matches. Why does that happen?
Also, input() returns string and randint() integers
Charly RománShow the error
File "F:\python cod\chatbott.py", line 14
gus = int(input("hadst:"))
^
SyntaxError: invalid syntax
PS F:\python cod>
•𝕋𝕚𝕥𝕒𝕟𝕏⦅卐⦆•File "F:\python cod\chatbott.py", line 14
gus = int(input("hadst:"))
^
SyntaxError: invalid syntax
PS F:\python cod>
In the elif you have a dot that shouldn't be there
Charly RománIn the elif you have a dot that shouldn't be there
This code is a complete chatbot, but only the game part is giving an error.
•𝕋𝕚𝕥𝕒𝕟𝕏⦅卐⦆•This code is a complete chatbot, but only the game part is giving an error.
yeah the dot shouldn't be there
Charly Rományeah the dot shouldn't be there
Oh, so I put a dot in the code? Got it.
thanks for your help🙏
29 August 2025
Peter Nuillx= [17,8,3]
y=x
y[0]=9
print (x)
[9,8,3]
What’s reason of it ?
Yesterday I was studying python.
And testing some rules.
I think the reason is that when you assign x to y. And x is a list.
Then the assignment pass the pointer or location in memory to y.
In this sense x and y point to the same object
Peter Nuillx= [17,8,3]
y=x
y[0]=9
print (x)
[9,8,3]
What’s reason of it ?
y is a reference not a copy of the first list
Peter Nuillx= [17,8,3]
y=x
y[0]=9
print (x)
[9,8,3]
What’s reason of it ?
if y=x
so x=y
now if y[0] val changes to 9
it means x[0] val changed to 9
so the x is returning [9,8,3]
technical term will:
print(id(x))
print(id(y))
u will see they are pointing to a single object in memory
Mamuliif y=x
so x=y
now if y[0] val changes to 9
it means x[0] val changed to 9
so the x is returning [9,8,3]
technical term will:
print(id(x))
print(id(y))
u will see they are pointing to a single object in memory
Shouldn't CPython copy value to other memory cell and link it to x variable?