Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
answer=input(print('What s the capital',country,'?'))
RETURN
What s the capital of South Africa ?
None
And I have to put my answer just after the 'none'
You are printing inside the input function and print returns None.
You should do something like this:
country = "Italy"
answer = input(f"What's the capital of {country}? ")
print(answer)
Read the documentation here.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 days ago.
Improve this question
how I can How can I do it the other hay around, for example, I want my program to be able to ask me for the value of r1 and vote for the level like this Input is 10000000 and the result is 10001, which would be the level
nivel = 10001 - 1
re = nivel**2
re1 = re *10
print (f"\nnivel 7014 : {re1}")
I don't know how I can solve it
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 months ago.
Improve this question
So I want to convert strings to shapes after being given a certain string by the user.
e.g "I love squares" = square shape.
what about just looking for the word to convert to in the string? something like this:
userstring = "I love squares"
if not userstring.find('squares') == -1:
create_square()
if not userstring.find('circle') == -1:
create_circle()
#etc etc
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
eg-In this instead of using 21 (a value), I want to use a variable to generalize it
print("{:-^21}".format(".|."*(2*(i+1)-1)))
I want to use something like this
print("{:-^M}".format(".|."*(2*(i+1)-1)))
That can easily enough be done. For example:
M = 40
i = 3
print("{val:-^{width}}".format(width=M, val=".|."*(2*(i+1)-1)))
Outputs:
---------.|..|..|..|..|..|..|.----------
You could also do it with f-strings (note the outer ' because " is used on the inner expression):
print(f'{".|."*(2*(i+1)-1):-^{M}}')
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I want to give a pattern to my strings in a python script.
I mean something like this:
x = "hello" + anyString
Note: this anyStringcan be anything even nothing
Update:
at this code, I want to type anything at the end of the string and get the same result
userCommand = input("you> ")
if userCommand == "hello":
print("hi!")
result:
you> hello
hi!
i want to get same result when i type anything else after hello something like this:hello!
userCommand = input("you> ")
if userCommand.startswith("hello"):
print("hi!")
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
name = input("What is your name?")
if name = Bob:
print ("Hi")
I am a beginner in python so it would be greatly appreciated if you would give an explanation or simple answer
-thanks
if name == "Bob":
print ("Hi")
Use == for comparison, and string variables should be within quotes:
if name == "Bob":
print ("Hi")