wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
[24, 61, 41 | [24, 61, 41] | Close bracket. | Python |
print 'value' | print('value') | print needs parentheses. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
let z: i32 = "value"; | let z: &str = "value"; | Type mismatch. | Rust |
if (x = 64) | if (x == 64) | Use ==. | C++ |
if (item = 81) | if (item == 81) | Use ==. | R |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
my @arr = (33,22,80); | my @arr = (33,22,80); | Correct. | Perl |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:2}}; | Add missing property. | TypeScript |
[x*x for x in arr if x > 86] | [x*x for x in arr if x > 86] | Correct list comprehension. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
class Product {{ int val; }}
obj.val=5; | class Product {{ public int val; }}
obj.val=5; | Make field public. | Java |
num = 46 | num=46 | No spaces. | Shell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
def process(y):
return y + 1 | def process(y):
return y + 1 | Correct. | Python |
DELETE FROM products WHERE name=43 | DELETE FROM products WHERE name=43; | Add semicolon. | SQL |
b > 74 & a < 54 | b > 74 and a < 54 | Use 'and' not '&'. | Python |
if (val = 8) {} | if (val == 8) {} | Use ==. | Dart |
'hello' + 97 | 'hello' + str(97) | Can't add int to string. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
if (item = 96) | if (item == 96) | Use ==. | Scala |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(95); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(95, () => console.log('listening')); | Add callback. | Node.js |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
$y = 96; if ($y = 96) {{}} | $y = 96; if ($y == 96) {{}} | Use ==. | PHP |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
JOIN products ON products.id = products.age | JOIN products ON products.id = products.age | Correct. | SQL |
let z: Int = 'hello' | let z: String = 'hello' | Fix type. | Swift |
render | render() | Add parentheses. | Kotlin |
println('data') | println("data") | Double quotes. | Scala |
name: test
age: 74 | name: test
age: 74 | Correct. | YAML |
const item; | const item = 100; | Initialize const. | JavaScript |
yield temp | yield temp | Correct yield. | Python |
echo message test | echo 'message test' | Quote to prevent splitting. | Shell |
WHERE name = '94' | WHERE name = 94 | Don't quote integer. | SQL |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
if ($item = 10) {{}} | if ($item -eq 10) {{}} | Use -eq. | PowerShell |
if data = 82: | if data == 82: | Use == for comparison. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if c = 96 then
print('hello')
end | if c == 96 then
print('hello')
end | Use ==. | Lua |
int[] values = new int[32];
values[32] = 5; | int[] values = new int[32];
if (32 < values.length) values[32] = 5; | Check bounds. | Java |
val x = 'hello' | val x = "hello" | Double quotes. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
while x > 74
x -= 1 | while x > 74:
x -= 1 | Colon missing after while. | Python |
// comment | /* comment */ | Use /* */. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
jwt.sign({{id:97}}, 'key'); | jwt.sign({{id:97}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
if bar = 88 | if bar == 88 | Use ==. | MATLAB |
else
print('message') | else:
print('message') | Colon after else. | Python |
print 'info' | print 'info'; | Add semicolon. | Perl |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
items[44] | if items.indices.contains(44) {{ items[44] }} | Check index. | Swift |
def foo():
print('message') | def foo():
print('message') | Indent function body. | Python |
h1 {{ font-size:43px color:green; }} | h1 {{ font-size:43px; color:green; }} | Add semicolon. | CSS |
{{'id':'world'}} | {{"id":"world"}} | Use double quotes. | JSON |
print('info') | print('info') | Correct. | R |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for (int i=0; i<49; i++) {{}} | for (int i=0; i<49; i++) {{}} | Correct. | Java |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
for x in range(32)
print(x) | for x in range(32):
print(x) | Colon after for. | Python |
'world' + 63 | 'world' + 63.to_s | Convert int. | Ruby |
const temp; | const temp = 27; | Initialize const. | JavaScript |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
if index = 29: | if index == 29: | Use == for comparison. | Python |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
{{"title":"test" "id":24}} | {{"title":"test", "id":24}} | Add comma. | JSON |
class Order {{ int x; }}
obj.x=5; | class Order {{ public int x; }}
obj.x=5; | Make field public. | Java |
JOIN orders ON orders.id = orders.id | JOIN orders ON orders.id = orders.id | Correct. | SQL |
disp('output') | disp('output') | Correct. | MATLAB |
switch(b){{ case 1: break; }} | switch(b){{ case 1: break; default: break; }} | Add default case. | Java |
List(33,22,58) | List(33,22,58) | Correct. | Scala |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
int data[77]; data[77]=5; | int data[77]; if(77<77){{}} else data[77]=5; | Bounds check. | C++ |
<person><name>hello</name><name>4</name></person | <person><name>hello</name><name>4</name></person> | Add closing >. | XML |
function foo() {{ echo 'info'; }} | function foo() {{ echo 'info'; }} | Correct. | PHP |
name: result
age: test, | name: result
age: test | Remove comma. | YAML |
if bar = 31 then
print('world')
end | if bar == 31 then
print('world')
end | Use ==. | Lua |
local x = 37 | local x = 37 | Correct. | Lua |
WHERE name = '10' | WHERE name = 10 | Don't quote integer. | SQL |
function handle() {{
return
{{key:'result'}}
}} | function handle() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
[36, 11, 76 | [36, 11, 76] | Close bracket. | Ruby |
def handle
puts 'message'
end | def handle
puts 'message'
end | Correct. | Ruby |
let data = 27; let data = 81; | let data = 27; data = 81; | Duplicate declaration. | JavaScript |
let item = 96; | let item = 96; | Correct. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.