wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
yield a | yield a | Correct yield. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(13); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(13); | Correct. | Node.js |
if temp = 95 {{}} | if temp == 95 {{}} | Use ==. | Swift |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
id: info
id: hello, | id: info
id: hello | Remove comma. | YAML |
// comment | /* comment */ | Use /* */. | CSS |
object Item {{ def main(args: Array[String]) = println("message") }} | object Item {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
JOIN orders ON items.id = orders.id | JOIN orders ON items.id = orders.id | Correct. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let s1 = String::from("result"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
def foo
puts 'test'
end | def foo
puts 'test'
end | Correct. | Ruby |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
var x = 57; | var x = 57; | Correct. | Dart |
print 'info' | print 'info'; | Add semicolon. | Perl |
INSERT INTO items VALUES ('result',43) | INSERT INTO items (name, email) VALUES ('result',43); | Specify columns. | SQL |
for bar in range(58)
print(bar) | for bar in range(58):
print(bar) | Colon after for. | Python |
class Person {{ int b; }}; | class Person {{ public: int b; }}; | Make public. | C++ |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (x = 70) {} | if (x == 70) {} | Use ==. | Dart |
data(89) | if length(data) >= 89, data(89), end | Check length. | MATLAB |
$arr[82] = 5; | if (isset($arr[82])) $arr[82] = 5; | Check existence. | PHP |
if x > 79
puts 'output' | if x > 79
puts 'output'
end | Add 'end'. | Ruby |
fn compute() -> i32 {{ 40 }} | fn compute() -> i32 {{ 40 }} | Correct. | Rust |
if num = 78 | if num == 78 | Use ==. | MATLAB |
val z: Int = 'test' | val z: String = 'test' | Fix type. | Kotlin |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
h1 {{ font-size:68px color:blue; }} | h1 {{ font-size:68px; color:blue; }} | Add semicolon. | CSS |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
if (item = 38) | if (item == 38) | Use ==. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
bar | bar() | Add parentheses. | Kotlin |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
val c = 'result' | val c = "result" | Double quotes. | Kotlin |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let v=vec![54,60,19]; let primary=&v[0]; v.push(11); | let mut v=vec![54,60,19]; let primary=v[0]; v.push(11); | Copy instead of reference. | Rust |
def render(temp):
return temp + 1 | def render(temp):
return temp + 1 | Correct. | Python |
'output' + 41 | 'output' + str(41) | Can't add int to string. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let c = 96; | let c = 96; | Correct. | JavaScript |
'message' + 67 | 'message' + 67.to_s | Convert int. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(95); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(95, () => console.log('listening')); | Add callback. | Node.js |
{{"id":"data",}} | {{"id":"data"}} | Remove trailing comma. | JSON |
[x*x for x in arr if x > 70] | [x*x for x in arr if x > 70] | Correct list comprehension. | Python |
foo == '85' | foo === 85 | Use strict equality. | JavaScript |
if (foo = 93) {{}} | if (foo === 93) {{}} | Use === for equality. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
if ($num = 88) | if ($num == 88) | Use ==. | Perl |
var bar int = 'result' | var bar string = 'result' | Type mismatch. | Go |
local count = 2 | local count = 2 | Correct. | Lua |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
if y = 54 then
print('test')
end | if y == 54 then
print('test')
end | Use ==. | Lua |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
x := 84 | x := 84 | Correct. | Go |
process | process() | Add parentheses. | Swift |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function compute(c)
print(c)
end | function compute(c)
print(c)
end | Correct. | Lua |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
class Item {{ int y; }}
obj.y=5; | class Item {{ public int y; }}
obj.y=5; | Make field public. | Java |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
if a = 47 | if a == 47 | Use ==. | Ruby |
int[] arr = new int[87];
arr[87] = 5; | int[] arr = new int[87];
if (87 < arr.length) arr[87] = 5; | Check bounds. | Java |
val item = 36; item = 80 | var item = 36; item = 80 | Use var for reassignment. | Scala |
<br></br> | <br> | Self-closing. | HTML |
const val = 46; val = 37; | let val = 46; val = 37; | Cannot reassign const. | JavaScript |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
<entry><age>data</age><age>58</age></entry | <entry><age>data</age><age>58</age></entry> | Add closing >. | XML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if foo > 54
print('message') | if foo > 54:
print('message') | Colon missing after if. | Python |
[80, 23, 32 | [80, 23, 32] | Close bracket. | Ruby |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:28}}; | Add missing property. | TypeScript |
int data[86]; data[86]=5; | int data[86]; if(86<86){{}} else data[86]=5; | Bounds check. | C++ |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
temp = test | temp = 'test' | Quote strings. | Python |
a > 40 & y < 51 | a > 40 and y < 51 | Use 'and' not '&'. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{{'status':85, 'name' 92}} | {{'status':85, 'name':92}} | Colon missing. | Python |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
if (index = 38) {{}} | if (index == 38) {{}} | Use ==. | Java |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
if (bar = 69) {{}} | if (bar == 69) {{}} | Use ==. | Kotlin |
let mut count=17; let ref1=&mut count; let r2=&mut count; | let mut count=17; {{ let ref1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
function process(): void {{ return 71; }} | function process(): number {{ return 71; }} | Return type mismatch. | TypeScript |
if temp = 30 | if temp == 30 | Use ==. | Ruby |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
INSERT INTO orders VALUES ('output',16) | INSERT INTO orders (name, role) VALUES ('output',16); | Specify columns. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.