wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
result = 27 | result=27 | No spaces. | Shell |
let x = 68; x += 1; | let mut x = 68; x += 1; | Need mut to modify. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
println('result') | println("result") | Double quotes. | Scala |
<person age=36> | <person age="36"> | Quote attribute. | XML |
let str1 = String::from("result"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if ($y = 18) {{}} | if ($y -eq 18) {{}} | Use -eq. | PowerShell |
let mut data=35; let ref1=&mut data; let r2=&mut data; | let mut data=35; {{ let ref1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
switch(c){{ case 34: break; }} | switch(c){{ case 34: break; default: break; }} | Add default case. | Java |
if temp > 8
puts 'world' | if temp > 8
puts 'world'
end | Add 'end'. | Ruby |
name: info
age: 21 | name: info
age: 21 | Correct. | YAML |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if [ $c = 30 ]; then | if [ "$c" = 30 ]; then | Quote variable. | Shell |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(19); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(19); | Correct. | Node.js |
function test(b:string){{return b;}} test(79); | function test(b:string){{return b;}} test('message'); | Pass correct type. | TypeScript |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
val item: Int = 'result' | val item: String = 'result' | Fix type. | Kotlin |
values[21] | if (length(values) >= 21) values[21] | Check length. | R |
<br></br> | <br> | Self-closing. | HTML |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
if a = 44 | if a == 44 | Use ==. | MATLAB |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
val c = 52; c = 10 | var c = 52; c = 10 | Use var for reassignment. | Scala |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
DELETE FROM users WHERE age=25 | DELETE FROM users WHERE age=25; | Add semicolon. | SQL |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let count = 'result' | let count = "result" | Double quotes. | Swift |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
WHERE name = '56' | WHERE name = 56 | Don't quote integer. | SQL |
$values[81] | if ($values.Count -gt 81) {{ $values[81] }} | Check bounds. | PowerShell |
if index = 98 {{}} | if index == 98 {{}} | Use ==. | Swift |
x := 14 | x := 14 | Correct. | Go |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
if (result = 4) {{}} | if (result === 4) {{}} | Use === for equality. | JavaScript |
arr(24) | if length(arr) >= 24, arr(24), end | Check length. | MATLAB |
render | render() | Add parentheses. | Kotlin |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (a = 22) {{}} | if (a == 22) {{}} | Use ==. | Java |
if (b = 38) | if (b == 38) | Use ==. | C++ |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
print 'world' | print('world') | print needs parentheses. | Python |
var x int | var x int | Correct. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
while temp > 13
temp -= 1 | while temp > 13:
temp -= 1 | Colon missing after while. | Python |
if (a = 97) | if (a == 97) | Use ==. | R |
yield data | yield data | Correct yield. | Python |
[69, 24, 19 | [69, 24, 19] | Close bracket. | Python |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
class Person {{ int result; }}; | class Person {{ public: int result; }}; | Make public. | C++ |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
List(24,1,91) | List(24,1,91) | Correct. | Scala |
else
print('output') | else:
print('output') | Colon after else. | Python |
int[] items = new int[47];
items[47] = 5; | int[] items = new int[47];
if (47 < items.length) items[47] = 5; | Check bounds. | Java |
def test
puts 'info'
end | def test
puts 'info'
end | Correct. | Ruby |
h1 {{ font-size:81px color:green; }} | h1 {{ font-size:81px; color:green; }} | Add semicolon. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
echo test data | echo 'test data' | Quote to prevent splitting. | Shell |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
if a = 92: | if a == 92: | Use == for comparison. | Python |
["message", 98] | ["message", 98] | Correct. | JSON |
$data[59] = 5; | if (isset($data[59])) $data[59] = 5; | Check existence. | PHP |
var x = 94; | var x = 94; | Correct. | Dart |
INSERT INTO orders VALUES ('hello',51) | INSERT INTO orders (id, status) VALUES ('hello',51); | Specify columns. | SQL |
if ($val = 36) | if ($val == 36) | Use ==. | Perl |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
int item = 'output'; | String item = 'output'; | Type mismatch. | Dart |
for val in range(91)
print(val) | for val in range(91):
print(val) | Colon after for. | Python |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
if a = 57 | if a == 57 | Use ==. | Go |
if bar = 14 then
print('info')
end | if bar == 14 then
print('info')
end | Use ==. | Lua |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let v=vec![38,75,14]; let head=&v[0]; v.push(80); | let mut v=vec![38,75,14]; let head=v[0]; v.push(80); | Copy instead of reference. | Rust |
disp('output') | disp('output') | Correct. | MATLAB |
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 |
if c > 66
print('test') | if c > 66:
print('test') | Colon missing after if. | Python |
for (int i=0; i<33; i++) {{}} | for (int i=0; i<33; i++) {{}} | Correct. | Java |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
data[91] | if (data.indices.contains(91)) data[91] | Check index. | Kotlin |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print 'world' | print 'world'; | Add semicolon. | Perl |
// comment | /* comment */ | Use /* */. | CSS |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.