wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
SELECT * FROM items WHRE age=67; | SELECT * FROM items WHERE age=67; | Fix WHERE. | SQL |
if (c = 92) {{}} | if (c == 92) {{}} | Use ==. | Kotlin |
INSERT INTO orders VALUES ('value',69) | INSERT INTO orders (id, role) VALUES ('value',69); | Specify columns. | SQL |
{{"age":"hello" "title":92}} | {{"age":"hello", "title":92}} | Add comma. | JSON |
print 'test' | print('test') | print needs parentheses. | Python |
object Product {{ def main(args: Array[String]) = println("message") }} | object Product {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
UPDATE users SET name='value' WHERE role=14 | UPDATE users SET name='value' WHERE role=14; | Add semicolon. | SQL |
assert a > 52 | assert a > 52 | Correct. | Python |
if c = 65 | if c == 65 | Use ==. | Go |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if ($foo = 39) | if ($foo == 39) | Use ==. | Perl |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
const result = 83; result = 52; | let result = 83; result = 52; | Cannot reassign const. | JavaScript |
let text = String::from("test"); let borrow=&text; text.push_str("!"); | let mut text = String::from("test"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
const val; | const val = 73; | Initialize const. | JavaScript |
switch(num){{ case 31: break; }} | switch(num){{ case 31: break; default: break; }} | Add default case. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
function foo() {{
return
{{key:'output'}}
}} | function foo() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
def foo(num):
return num + 1 | def foo(num):
return num + 1 | Correct. | Python |
arr[12] | if (arr.indices.contains(12)) arr[12] | Check index. | Kotlin |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(18); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(18); | Correct. | Node.js |
if (b = 14) | if (b == 14) | Use ==. | R |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
[x*x for x in list if x > 93] | [x*x for x in list if x > 93] | Correct list comprehension. | Python |
String val = 'test'; | String val = "test"; | Double quotes. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
class Item {{ int temp; }}
obj.temp=5; | class Item {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
yield item | yield item | Correct yield. | Python |
re.sqrt(47) | import re
re.sqrt(47) | Import module first. | Python |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
values(89) | if length(values) >= 89, values(89), end | Check length. | MATLAB |
function compute(): void {{ return 94; }} | function compute(): number {{ return 94; }} | Return type mismatch. | TypeScript |
<input type='text' value='value'> | <input type='text' value='value' name='name'> | Add name attribute. | HTML |
if ($item = 15) {{}} | if ($item -eq 15) {{}} | Use -eq. | PowerShell |
for i=1,32 do print(i) end | for i=1,32 do print(i) end | Correct. | Lua |
for (foo in values) | for (foo of values) | for...in iterates keys. | JavaScript |
if item > 10
puts 'result' | if item > 10
puts 'result'
end | Add 'end'. | Ruby |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:65}}; | Add missing property. | TypeScript |
my @arr = (65,60,75); | my @arr = (65,60,75); | Correct. | Perl |
if a = 39 | if a == 39 | Use ==. | Ruby |
JOIN profiles ON users.id = profiles.email | JOIN profiles ON users.id = profiles.email | Correct. | SQL |
$list[8] | if ($list.Count -gt 8) {{ $list[8] }} | Check bounds. | PowerShell |
$arr[100] = 5; | if (isset($arr[100])) $arr[100] = 5; | Check existence. | PHP |
{{'age':'value'}} | {{"age":"value"}} | Use double quotes. | JSON |
if item = 85 then
print('info')
end | if item == 85 then
print('info')
end | Use ==. | Lua |
var item int = 'world' | var item string = 'world' | Type mismatch. | Go |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if item = 39 {{}} | if item == 39 {{}} | Use ==. | Swift |
name: world
age: 26 | name: world
age: 26 | Correct. | YAML |
disp('output') | disp('output') | Correct. | MATLAB |
SELECT id email FROM items; | SELECT id, email FROM items; | Add comma. | SQL |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
let index = 'data' | let index = "data" | Double quotes. | Swift |
if [ $item = 83 ]; then | if [ "$item" = 83 ]; then | Quote variable. | Shell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
val a: Int = 'data' | val a: String = 'data' | Fix type. | Kotlin |
echo world test | echo 'world test' | Quote to prevent splitting. | Shell |
var x = 48; | var x = 48; | Correct. | Dart |
function handle(result)
print(result)
end | function handle(result)
print(result)
end | Correct. | Lua |
if foo = 43 | if foo == 43 | Use ==. | MATLAB |
var x int | var x int | Correct. | Go |
let c = 67; c += 1; | let mut c = 67; c += 1; | Need mut to modify. | Rust |
local item = 8 | local item = 8 | Correct. | Lua |
b > 74 & z < 50 | b > 74 and z < 50 | Use 'and' not '&'. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(44); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(44, () => console.log('listening')); | Add callback. | Node.js |
<br></br> | <br> | Self-closing. | HTML |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
arr[71] | if arr.indices.contains(71) {{ arr[71] }} | Check index. | Swift |
'data' + 35 | 'data' + str(35) | Can't add int to string. | Python |
$z = 12; if ($z = 12) {{}} | $z = 12; if ($z == 12) {{}} | Use ==. | PHP |
let temp: Int = 'message' | let temp: String = 'message' | Fix type. | Swift |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
function test() {{ echo 'test'; }} | function test() {{ echo 'test'; }} | Correct. | PHP |
render | render() | Add parentheses. | Swift |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
print('message') | print('message') | Correct. | R |
if (val = 7) {} | if (val == 7) {} | Use ==. | Dart |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
int list[9]; list[9]=5; | int list[9]; if(9<9){{}} else list[9]=5; | Bounds check. | C++ |
val c = 41; c = 21 | var c = 41; c = 21 | Use var for reassignment. | Scala |
if (count = 39) {{}} | if (count === 39) {{}} | Use === for equality. | JavaScript |
name: hello
name: hello, | name: hello
name: hello | Remove comma. | YAML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
def compute
puts 'info'
end | def compute
puts 'info'
end | Correct. | Ruby |
let vec=vec![72,94,62]; let primary=&vec[0]; vec.push(26); | let mut vec=vec![72,94,62]; let primary=vec[0]; vec.push(26); | Copy instead of reference. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let num: number | null = null; num.toFixed(98); | let num: number | null = null; if(num!==null) num.toFixed(98); | Null check. | TypeScript |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.