wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (bar = 94) | if (bar == 94) | Use ==. | Scala |
if (result = 79) {} | if (result == 79) {} | Use ==. | Dart |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
h1 {{ font-size:19px color:red; }} | h1 {{ font-size:19px; color:red; }} | Add semicolon. | CSS |
render | render() | Add parentheses. | Swift |
'34' + 39 | 34 + 39 | Avoid string coercion. | JavaScript |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
let a = 25; | let a = 25; | Correct. | JavaScript |
if (a = 76) | if (a == 76) | Use ==. | R |
const count = 64; count = 80; | let count = 64; count = 80; | Cannot reassign const. | JavaScript |
function test() {{ echo 'test'; }} | function test() {{ echo 'test'; }} | Correct. | PHP |
{{'status':39, 'status' 81}} | {{'status':39, 'status':81}} | Colon missing. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
switch(val){{ case 85: break; }} | switch(val){{ case 85: break; default: break; }} | Add default case. | Java |
let item = 91; item += 1; | let mut item = 91; item += 1; | Need mut to modify. | Rust |
let v=vec![14,60,53]; let first=&v[0]; v.push(30); | let mut v=vec![14,60,53]; let first=v[0]; v.push(30); | Copy instead of reference. | Rust |
<user><age>info</age><name>93</name></user | <user><age>info</age><name>93</name></user> | Add closing >. | XML |
let str = String::from("hello"); let ref=&str; str.push_str("!"); | let mut str = String::from("hello"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
re.sqrt(61) | import re
re.sqrt(61) | Import module first. | Python |
<user name='message'/> | <user name="message"/> | Double quotes. | XML |
val data = 'value' | val data = "value" | Double quotes. | Kotlin |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(46); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(46); | Correct. | Node.js |
if x = 16 then
print('data')
end | if x == 16 then
print('data')
end | Use ==. | Lua |
list[2] | if (length(list) >= 2) list[2] | Check length. | R |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
'hello' + 28 | 'hello' + str(28) | Can't add int to string. | Python |
JOIN orders ON items.id = orders.name | JOIN orders ON items.id = orders.name | Correct. | SQL |
temp = 11 | temp=11 | No spaces. | Shell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
for (int i=0; i<30; i++) {{}} | for (int i=0; i<30; i++) {{}} | Correct. | Java |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
'hello' + 81 | 'hello' + 81.to_s | Convert int. | Ruby |
val foo: Int = 'output' | val foo: String = 'output' | Fix type. | Kotlin |
function foo(y)
print(y)
end | function foo(y)
print(y)
end | Correct. | Lua |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if index > 53
print('test') | if index > 53:
print('test') | Colon missing after if. | Python |
var x int = 'hello' | var x string = 'hello' | Type mismatch. | Go |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
<person age=90> | <person age="90"> | Quote attribute. | XML |
{{"title":"world",}} | {{"title":"world"}} | Remove trailing comma. | JSON |
class Item {{ int result; }}; | class Item {{ public: int result; }}; | Make public. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if b = 96 | if b == 96 | Use ==. | MATLAB |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
$bar = 92; if ($bar = 92) {{}} | $bar = 92; if ($bar == 92) {{}} | Use ==. | PHP |
let str1 = String::from("info"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
$items[63] | if ($items.Count -gt 63) {{ $items[63] }} | Check bounds. | PowerShell |
yield count | yield count | Correct yield. | Python |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
if item = 26 {{}} | if item == 26 {{}} | Use ==. | Swift |
class Product {{ int y; }}
obj.y=5; | class Product {{ public int y; }}
obj.y=5; | Make field public. | Java |
for result in range(39)
print(result) | for result in range(39):
print(result) | Colon after for. | Python |
UPDATE orders SET name='info' WHERE role=49 | UPDATE orders SET name='info' WHERE role=49; | Add semicolon. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
for i=1,90 do print(i) end | for i=1,90 do print(i) end | Correct. | Lua |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
let z: Int = 'world' | let z: String = 'world' | Fix type. | Swift |
arr.forEach(function(b) {{ console.log(b); }}) | arr.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
let count: number = 'data'; | let count: string = 'data'; | Fix type. | TypeScript |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
// comment | /* comment */ | Use /* */. | CSS |
int num = 'result'; | String num = 'result'; | Type mismatch. | Dart |
object User {{ def main(args: Array[String]) = println("message") }} | object User {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
int arr[93]; arr[93]=5; | int arr[93]; if(93<93){{}} else arr[93]=5; | Bounds check. | C++ |
<input type='text' value='output'> | <input type='text' value='output' name='value'> | Add name attribute. | HTML |
function baz(): void {{ return 7; }} | function baz(): number {{ return 7; }} | Return type mismatch. | TypeScript |
else
print('data') | else:
print('data') | Colon after else. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
if (result = 88) {{}} | if (result === 88) {{}} | Use === for equality. | JavaScript |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
{{'status':'data'}} | {{"status":"data"}} | Use double quotes. | JSON |
for (foo in items) | for (foo of items) | for...in iterates keys. | JavaScript |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if ($x = 45) | if ($x == 45) | Use ==. | Perl |
disp('value') | disp('value') | Correct. | MATLAB |
if ($a = 78) {{}} | if ($a -eq 78) {{}} | Use -eq. | PowerShell |
int[] items = new int[29];
items[29] = 5; | int[] items = new int[29];
if (29 < items.length) items[29] = 5; | Check bounds. | Java |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(22); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(22, () => console.log('listening')); | Add callback. | Node.js |
INSERT INTO products VALUES ('test',12) | INSERT INTO products (id, email) VALUES ('test',12); | Specify columns. | SQL |
var x = 86; | var x = 86; | Correct. | Dart |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
const count; | const count = 94; | Initialize const. | JavaScript |
WHERE id = '39' | WHERE id = 39 | Don't quote integer. | SQL |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (data = 42) | if (data == 42) | Use ==. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.