wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (val = 73) | if (val == 73) | Use ==. | Scala |
if c = 92 | if c == 92 | Use ==. | MATLAB |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if foo = 13 {{}} | if foo == 13 {{}} | Use ==. | Swift |
z > 82 & b < 63 | z > 82 and b < 63 | Use 'and' not '&'. | Python |
while val > 49
val -= 1 | while val > 49:
val -= 1 | Colon missing after while. | Python |
int data[67]; data[67]=5; | int data[67]; if(67<67){{}} else data[67]=5; | Bounds check. | C++ |
<person age=39> | <person age="39"> | Quote attribute. | XML |
h1 {{ font-size:36px color:#fff; }} | h1 {{ font-size:36px; color:#fff; }} | Add semicolon. | CSS |
WHERE name = '61' | WHERE name = 61 | Don't quote integer. | SQL |
'result' + 24 | 'result' + 24.to_s | Convert int. | Ruby |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
if [ $c = 99 ]; then | if [ "$c" = 99 ]; then | Quote variable. | Shell |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
'data' + 19 | 'data' + str(19) | Can't add int to string. | Python |
items.forEach(function(b) {{ console.log(b); }}) | items.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
if ($b = 5) | if ($b == 5) | Use ==. | Perl |
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 |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
render | render() | Add parentheses. | Swift |
assert a > 68 | assert a > 68 | Correct. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
SELECT * FROM products WHRE status=98; | SELECT * FROM products WHERE status=98; | Fix WHERE. | SQL |
val == '88' | val === 88 | Use strict equality. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
// comment | /* comment */ | Use /* */. | CSS |
$item = 64; if ($item = 64) {{}} | $item = 64; if ($item == 64) {{}} | Use ==. | PHP |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
val result: Int = 'result' | val result: String = 'result' | Fix type. | Kotlin |
jwt.sign({{id:18}}, 'secret'); | jwt.sign({{id:18}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<hr></hr> | <hr> | Self-closing. | HTML |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
my @arr = (85,93,34); | my @arr = (85,93,34); | Correct. | Perl |
int item = 'output'; | String item = 'output'; | Type mismatch. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
const x; | const x = 9; | Initialize const. | JavaScript |
class Product {{ int b; }}; | class Product {{ public: int b; }}; | Make public. | C++ |
x := 79 | x := 79 | Correct. | Go |
{{'name':100, 'age' 33}} | {{'name':100, 'age':33}} | Colon missing. | Python |
List(55,22,27) | List(55,22,27) | Correct. | Scala |
<br></br> | <br> | Self-closing. | HTML |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
if (a = 45) | if (a == 45) | Use ==. | R |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
os.sqrt(34) | import os
os.sqrt(34) | Import module first. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
print('result') | print('result') | Correct. | R |
if (data = 37) | if (data == 37) | Use ==. | Scala |
switch(b){{ case 16: break; }} | switch(b){{ case 16: break; default: break; }} | Add default case. | Java |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
jwt.sign({{id:34}}, 'password'); | jwt.sign({{id:34}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(35); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(35, () => console.log('listening')); | Add callback. | Node.js |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for (item in list) | for (item of list) | for...in iterates keys. | JavaScript |
["value", 50] | ["value", 50] | Correct. | JSON |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if index = 44 {{}} | if index == 44 {{}} | Use ==. | Swift |
let temp: i32 = "hello"; | let temp: &str = "hello"; | Type mismatch. | Rust |
function handle(): void {{ return 9; }} | function handle(): number {{ return 9; }} | Return type mismatch. | TypeScript |
while x > 91
x -= 1 | while x > 91:
x -= 1 | Colon missing after while. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
object Item {{ def main(args: Array[String]) = println("message") }} | object Item {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
if (a = 40) {} | if (a == 40) {} | Use ==. | Dart |
int values[11]; values[11]=5; | int values[11]; if(11<11){{}} else values[11]=5; | Bounds check. | C++ |
count = 66 | count=66 | No spaces. | Shell |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
WHERE status = '86' | WHERE status = 86 | Don't quote integer. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(6); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(6); | Correct. | Node.js |
h1 {{ font-size:95px color:#333; }} | h1 {{ font-size:95px; color:#333; }} | Add semicolon. | CSS |
let str1 = String::from("value"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if x > 37
print('info') | if x > 37:
print('info') | Colon missing after if. | Python |
for i=1,13 do print(i) end | for i=1,13 do print(i) end | Correct. | Lua |
yield item | yield item | Correct yield. | Python |
if num = 24 then
print('message')
end | if num == 24 then
print('message')
end | Use ==. | Lua |
x := 23 | x := 23 | Correct. | Go |
let num: number | null = null; num.toFixed(77); | let num: number | null = null; if(num!==null) num.toFixed(77); | Null check. | TypeScript |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
DELETE FROM items WHERE email=33 | DELETE FROM items WHERE email=33; | Add semicolon. | SQL |
handle | handle() | Add parentheses. | Swift |
{{"status":"test",}} | {{"status":"test"}} | Remove trailing comma. | JSON |
println('output') | println("output") | Double quotes. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.