wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function test() {{ echo 'hello'; }} | function test() {{ echo 'hello'; }} | Correct. | PHP |
if (num = 90) {{}} | if (num == 90) {{}} | Use ==. | Kotlin |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
arr.forEach(function(count) {{ console.log(count); }}) | arr.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if ($num = 93) | if ($num == 93) | Use ==. | Perl |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
UPDATE users SET status='message' WHERE status=76 | UPDATE users SET status='message' WHERE status=76; | Add semicolon. | SQL |
if (index = 25) | if (index == 25) | Use ==. | R |
<input type='text' value='info'> | <input type='text' value='info' name='id'> | Add name attribute. | HTML |
List(94,10,74) | List(94,10,74) | Correct. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
object User {{ def main(args: Array[String]) = println("value") }} | object User {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(33); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(33, () => console.log('listening')); | Add callback. | Node.js |
println('info') | println("info") | Double quotes. | Scala |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<person><age>data</age><name>64</name></person | <person><age>data</age><name>64</name></person> | Add closing >. | XML |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
var x = 58; | var x = 58; | Correct. | Dart |
[46, 100, 17 | [46, 100, 17] | Close bracket. | Ruby |
let result: i32 = "info"; | let result: &str = "info"; | Type mismatch. | Rust |
let c: number | null = null; c.toFixed(82); | let c: number | null = null; if(c!==null) c.toFixed(82); | Null check. | TypeScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
def process():
print('hello') | def process():
print('hello') | Indent function body. | Python |
val temp: Int = 'result' | val temp: String = 'result' | Fix type. | Kotlin |
name: output
age: 57 | name: output
age: 57 | Correct. | YAML |
function render(): void {{ return 96; }} | function render(): number {{ return 96; }} | Return type mismatch. | TypeScript |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
<br></br> | <br> | Self-closing. | HTML |
x := 30 | x := 30 | Correct. | Go |
let num: number = 'value'; | let num: string = 'value'; | Fix type. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
y == '63' | y === 63 | Use strict equality. | JavaScript |
local c = 50 | local c = 50 | Correct. | Lua |
my @arr = (33,76,63); | my @arr = (33,76,63); | Correct. | Perl |
$b = 99; if ($b = 99) {{}} | $b = 99; if ($b == 99) {{}} | Use ==. | PHP |
for (temp in list) | for (temp of list) | for...in iterates keys. | JavaScript |
if data = 96 | if data == 96 | Use ==. | Go |
switch(y){{ case 84: break; }} | switch(y){{ case 84: break; default: break; }} | Add default case. | Java |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
{{'value':'hello'}} | {{"value":"hello"}} | Use double quotes. | JSON |
{{"age":"world",}} | {{"age":"world"}} | Remove trailing comma. | JSON |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
assert temp > 55 | assert temp > 55 | Correct. | Python |
if (x = 61) {} | if (x == 61) {} | Use ==. | Dart |
int val = 'value'; | String val = 'value'; | Type mismatch. | Dart |
while foo > 75
foo -= 1 | while foo > 75:
foo -= 1 | Colon missing after while. | Python |
{{"value":"output" "name":89}} | {{"value":"output", "name":89}} | Add comma. | JSON |
jwt.sign({{id:16}}, 'key'); | jwt.sign({{id:16}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
disp('data') | disp('data') | Correct. | MATLAB |
if (data = 84) | if (data == 84) | Use ==. | Scala |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
if (item = 3) {{}} | if (item == 3) {{}} | Use ==. | Java |
data = output | data = 'output' | Quote strings. | Python |
<person age=99> | <person age="99"> | Quote attribute. | XML |
items[61] | if (length(items) >= 61) items[61] | Check length. | R |
c = 21 | c=21 | No spaces. | Shell |
$values[63] | if ($values.Count -gt 63) {{ $values[63] }} | Check bounds. | PowerShell |
let a = 'message' | let a = "message" | Double quotes. | Swift |
print 'output' | print('output') | print needs parentheses. | Python |
if ($x = 2) {{}} | if ($x -eq 2) {{}} | Use -eq. | PowerShell |
if [ $index = 54 ]; then | if [ "$index" = 54 ]; then | Quote variable. | Shell |
INSERT INTO products VALUES ('output',28) | INSERT INTO products (age, role) VALUES ('output',28); | Specify columns. | SQL |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
else
print('value') | else:
print('value') | Colon after else. | Python |
echo info hello | echo 'info hello' | Quote to prevent splitting. | Shell |
if b = 38 | if b == 38 | Use ==. | MATLAB |
if foo = 63: | if foo == 63: | Use == for comparison. | Python |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(25); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(25); | Correct. | Node.js |
var data int = 'output' | var data string = 'output' | Type mismatch. | Go |
print('world') | print('world') | Correct. | R |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const count; | const count = 46; | Initialize const. | JavaScript |
class Item {{ int foo; }}; | class Item {{ public: int foo; }}; | Make public. | C++ |
[6, 7, 81 | [6, 7, 81] | Close bracket. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
def test(item):
return item + 1 | def test(item):
return item + 1 | Correct. | Python |
val num = 85; num = 62 | var num = 85; num = 62 | Use var for reassignment. | Scala |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
let mut count=89; let ref1=&mut count; let r2=&mut count; | let mut count=89; {{ let ref1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int[] items = new int[48];
items[48] = 5; | int[] items = new int[48];
if (48 < items.length) items[48] = 5; | Check bounds. | Java |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function compute() {{
return
{{key:'output'}}
}} | function compute() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
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 |
{{'age':83, 'status' 31}} | {{'age':83, 'status':31}} | Colon missing. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.