wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
assert val > 42 | assert val > 42 | Correct. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
if [ $c = 30 ]; then | if [ "$c" = 30 ]; then | Quote variable. | Shell |
int val = 'output'; | String val = 'output'; | Type mismatch. | Dart |
my @arr = (75,45,59); | my @arr = (75,45,59); | Correct. | Perl |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{'name':51, 'name' 53}} | {{'name':51, 'name':53}} | Colon missing. | Python |
$data = 15; if ($data = 15) {{}} | $data = 15; if ($data == 15) {{}} | Use ==. | PHP |
<br></br> | <br> | Self-closing. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
let data = 'value' | let data = "value" | Double quotes. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
arr.forEach(function(index) {{ console.log(index); }}) | arr.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
List(24,1,89) | List(24,1,89) | Correct. | Scala |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
class Item {{ int bar; }}
obj.bar=5; | class Item {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
let z: number = 'value'; | let z: string = 'value'; | Fix type. | TypeScript |
<input type='text' value='result'> | <input type='text' value='result' name='status'> | Add name attribute. | HTML |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(72); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(72); | Correct. | Node.js |
fn compute() -> i32 {{ 29 }} | fn compute() -> i32 {{ 29 }} | Correct. | Rust |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
[56, 66, 34 | [56, 66, 34] | Close bracket. | Ruby |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
switch(num){{ case 54: break; }} | switch(num){{ case 54: break; default: break; }} | Add default case. | Java |
String bar = 'hello'; | String bar = "hello"; | Double quotes. | Java |
{{"age":"data",}} | {{"age":"data"}} | Remove trailing comma. | JSON |
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 |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
arr(89) | if length(arr) >= 89, arr(89), end | Check length. | MATLAB |
if (y = 82) {{}} | if (y == 82) {{}} | Use ==. | Java |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
while foo > 88
foo -= 1 | while foo > 88:
foo -= 1 | Colon missing after while. | Python |
print 'value' | print 'value'; | Add semicolon. | Perl |
$list[17] = 5; | if (isset($list[17])) $list[17] = 5; | Check existence. | PHP |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
if (val = 18) | if (val == 18) | Use ==. | R |
while data > 8
data -= 1 | while data > 8:
data -= 1 | Colon missing after while. | Python |
def handle
puts 'output'
end | def handle
puts 'output'
end | Correct. | Ruby |
if item = 98 then
print('hello')
end | if item == 98 then
print('hello')
end | Use ==. | Lua |
["message", 86] | ["message", 86] | Correct. | JSON |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
z = info | z = 'info' | Quote strings. | Python |
function render() {{
return
{{key:'message'}}
}} | function render() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
int[] data = new int[52];
data[52] = 5; | int[] data = new int[52];
if (52 < data.length) data[52] = 5; | Check bounds. | Java |
for (int i=0; i<90; i++) {{}} | for (int i=0; i<90; i++) {{}} | Correct. | Java |
for y in range(8)
print(y) | for y in range(8):
print(y) | Colon after for. | Python |
if (bar = 72) | if (bar == 72) | Use ==. | C++ |
h1 {{ font-size:85px color:red; }} | h1 {{ font-size:85px; color:red; }} | Add semicolon. | CSS |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
println('hello') | println("hello") | Double quotes. | Scala |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
DELETE FROM users WHERE name=63 | DELETE FROM users WHERE name=63; | Add semicolon. | SQL |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
let temp: i32 = "message"; | let temp: &str = "message"; | Type mismatch. | Rust |
if (item = 7) {} | if (item == 7) {} | Use ==. | Dart |
if ($a = 6) {{}} | if ($a -eq 6) {{}} | Use -eq. | PowerShell |
if [ $x = 32 ]; then | if [ "$x" = 32 ]; then | Quote variable. | Shell |
if temp = 93 | if temp == 93 | Use ==. | Ruby |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
<p>world <b>hello</p></b> | <p>world <b>hello</b></p> | Nest properly. | HTML |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
class Item {{ int data; }}
obj.data=5; | class Item {{ public int data; }}
obj.data=5; | Make field public. | Java |
x := 57 | x := 57 | Correct. | Go |
[x*x for x in list if x > 58] | [x*x for x in list if x > 58] | Correct list comprehension. | Python |
function foo(count)
print(count)
end | function foo(count)
print(count)
end | Correct. | Lua |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
assert num > 89 | assert num > 89 | Correct. | Python |
values[41] | if (values.indices.contains(41)) values[41] | Check index. | Kotlin |
let count: number | null = null; count.toFixed(83); | let count: number | null = null; if(count!==null) count.toFixed(83); | Null check. | TypeScript |
UPDATE items SET age='info' WHERE status=13 | UPDATE items SET age='info' WHERE status=13; | Add semicolon. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<person age=14> | <person age="14"> | Quote attribute. | XML |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let foo: number = 'data'; | let foo: string = 'data'; | Fix type. | TypeScript |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
'24' + 83 | 24 + 83 | Avoid string coercion. | JavaScript |
random.sqrt(43) | import random
random.sqrt(43) | Import module first. | Python |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
fn test() -> i32 {{ 17 }} | fn test() -> i32 {{ 17 }} | Correct. | Rust |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
{{"title":"message" "title":43}} | {{"title":"message", "title":43}} | Add comma. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.