- 2
I want to input two value in one line, use of two data type.
For ex. Subject= english and marks= 80 (english and 80 the value taken from user)
15 Antworten
+ 4
Try this:
subject, marks = input().split()
print("Subject= ", subject, " and Marks= ",marks)
+ 4
Post your code here
+ 4
dear all,
when assigning the splitted values from input, there is no need to put the variable names in squared brackets.
subject, marks = input().split() # this is sufficient!
+ 3
♤♢☞ 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 ☜♢♤ ,
what are your doubts by using split() ?
+ 2
Can you be more clear?? Tell us the desired input and output atleast.
+ 2
You can input whatever you want using the the input function unless you specified it. So, if you want to take two different values from/byusing input function, you can do it like this,
[Subject, marks ] = input().split()
Then, submit the two values using whitespace.
+ 1
No its not working
+ 1
The above code only assigned the variables to something. You have to call/print or utilize them in some way. Like
[Subject, marks ] = input().split()
print('You have got {} in this {} subject'.format(marks, subject))
+ 1
Yes, it was work.
Thanks you so much bro🤗👍
+ 1
Whatever i know, split() is use for space between two numbers. Am i right?
+ 1
Kiibo ghayal
Your coding is correct but the value English and 80 would taken through the input() func. giving By user.
+ 1
Sachin Pradhan
Not only for spaces but for strings
0
Any body can solve my problem?i don't know this solution but want this type of ans?
print Subject=(input Math by user) as well print Marks=(input 75 by user) this output will come
Subject= math and Marks= 75
0
Lothar
Your code is wrong, its came👉 no output