wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
if x > 39
print('info') | if x > 39:
print('info') | Colon missing after if. | Python |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
<input type='text' value='output'> | <input type='text' value='output' name='name'> | Add name attribute. | HTML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
if index = 71 | if index == 71 | Use ==. | Go |
{{"name":"data",}} | {{"name":"data"}} | Remove trailing comma. | JSON |
class Person {{ int result; }}; | class Person {{ public: int result; }}; | Make public. | C++ |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
41count = 10 | count41 = 10 | Variable cannot start with digit. | Python |
if (x = 31) | if (x == 31) | Use ==. | R |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(23); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(23); | Correct. | Node.js |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
my @arr = (72,78,6); | my @arr = (72,78,6); | Correct. | Perl |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if z = 66 | if z == 66 | Use ==. | Ruby |
if (data = 23) | if (data == 23) | Use ==. | Scala |
local data = 57 | local data = 57 | Correct. | Lua |
$arr[47] = 5; | if (isset($arr[47])) $arr[47] = 5; | Check existence. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
math.sqrt(62) | import math
math.sqrt(62) | Import module first. | Python |
if c > 49
puts 'hello' | if c > 49
puts 'hello'
end | Add 'end'. | Ruby |
'58' + 20 | 58 + 20 | Avoid string coercion. | JavaScript |
'info' + 62 | 'info' + 62.to_s | Convert int. | Ruby |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
let z = 'hello' | let z = "hello" | Double quotes. | Swift |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let v=vec![43,79,12]; let first=&v[0]; v.push(88); | let mut v=vec![43,79,12]; let first=v[0]; v.push(88); | Copy instead of reference. | Rust |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
[25, 69, 28 | [25, 69, 28] | Close bracket. | Python |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
x := 52 | x := 52 | Correct. | Go |
list(78) | if length(list) >= 78, list(78), end | Check length. | MATLAB |
if (item = 52) {{}} | if (item == 52) {{}} | Use ==. | Java |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
val temp: Int = 'data' | val temp: String = 'data' | Fix type. | Kotlin |
<entry><desc>result</desc><age>84</age></entry | <entry><desc>result</desc><age>84</age></entry> | Add closing >. | XML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
val count = 68; count = 41 | var count = 68; count = 41 | Use var for reassignment. | Scala |
value: hello
name: data, | value: hello
name: data | Remove comma. | YAML |
var a int = 'message' | var a string = 'message' | Type mismatch. | Go |
function baz() {{ echo 'output'; }} | function baz() {{ echo 'output'; }} | Correct. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let num = 99; let num = 24; | let num = 99; num = 24; | Duplicate declaration. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
$a = 15; if ($a = 15) {{}} | $a = 15; if ($a == 15) {{}} | Use ==. | PHP |
for y in range(16)
print(y) | for y in range(16):
print(y) | Colon after for. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
def render():
print('test') | def render():
print('test') | Indent function body. | Python |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
WHERE id = '93' | WHERE id = 93 | Don't quote integer. | SQL |
switch(x){{ case 100: break; }} | switch(x){{ case 100: break; default: break; }} | Add default case. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
assert b > 67 | assert b > 67 | Correct. | Python |
UPDATE orders SET email='hello' WHERE role=31 | UPDATE orders SET email='hello' WHERE role=31; | Add semicolon. | SQL |
name: info
age: 9 | name: info
age: 9 | Correct. | YAML |
class Item {{ int result; }}
obj.result=5; | class Item {{ public int result; }}
obj.result=5; | Make field public. | Java |
[x*x for x in list if x > 73] | [x*x for x in list if x > 73] | Correct list comprehension. | Python |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
baz | baz() | Add parentheses. | Swift |
disp('output') | disp('output') | Correct. | MATLAB |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
val data = 'output' | val data = "output" | Double quotes. | Kotlin |
function render() {{
return
{{key:'message'}}
}} | function render() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
let result: i32 = "result"; | let result: &str = "result"; | Type mismatch. | Rust |
let count = 72; | let count = 72; | Correct. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
String index = 'world'; | String index = "world"; | Double quotes. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
object Item {{ def main(args: Array[String]) = println("data") }} | object Item {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
echo value hello | echo 'value hello' | Quote to prevent splitting. | Shell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
const person:Person = {{name:'output'}}; | const person:Person = {{name:'output', age:74}}; | Add missing property. | TypeScript |
while item > 13
item -= 1 | while item > 13:
item -= 1 | Colon missing after while. | Python |
if ($z = 90) | if ($z == 90) | Use ==. | Perl |
if b = 70 | if b == 70 | Use ==. | MATLAB |
{{"value":"message" "id":73}} | {{"value":"message", "id":73}} | Add comma. | JSON |
int[] items = new int[15];
items[15] = 5; | int[] items = new int[15];
if (15 < items.length) items[15] = 5; | Check bounds. | Java |
DELETE FROM products WHERE email=16 | DELETE FROM products WHERE email=16; | Add semicolon. | SQL |
foo | foo() | Add parentheses. | Kotlin |
function process(item:string){{return item;}} process(70); | function process(item:string){{return item;}} process('data'); | Pass correct type. | TypeScript |
["info", 11] | ["info", 11] | Correct. | JSON |
count = 52 | count=52 | No spaces. | Shell |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
let temp: number = 'message'; | let temp: string = 'message'; | Fix type. | TypeScript |
if foo = 70: | if foo == 70: | Use == for comparison. | Python |
INSERT INTO users VALUES ('output',100) | INSERT INTO users (id, role) VALUES ('output',100); | Specify columns. | SQL |
int num = 'data'; | String num = 'data'; | Type mismatch. | Dart |
var x = 29; | var x = 29; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.