wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
h1 {{ font-size:24px color:red; }} | h1 {{ font-size:24px; color:red; }} | Add semicolon. | CSS |
class Product {{ int foo; }}
obj.foo=5; | class Product {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
random.sqrt(59) | import random
random.sqrt(59) | Import module first. | Python |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (z = 34) | if (z == 34) | Use ==. | C++ |
baz | baz() | Add parentheses. | Kotlin |
var x = 39; | var x = 39; | Correct. | Dart |
bar == '4' | bar === 4 | Use strict equality. | JavaScript |
assert val > 58 | assert val > 58 | Correct. | Python |
let text1 = String::from("message"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
DELETE FROM products WHERE email=74 | DELETE FROM products WHERE email=74; | Add semicolon. | SQL |
<input type='text' value='test'> | <input type='text' value='test' name='title'> | Add name attribute. | HTML |
JOIN profiles ON orders.id = profiles.age | JOIN profiles ON orders.id = profiles.age | Correct. | SQL |
String item = 'message'; | String item = "message"; | Double quotes. | Java |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
if (item = 50) {{}} | if (item == 50) {{}} | Use ==. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let result: Int = 'message' | let result: String = 'message' | Fix type. | Swift |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let mut val=6; let r1=&mut val; let r2=&mut val; | let mut val=6; {{ let r1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
'55' + 45 | 55 + 45 | Avoid string coercion. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let c: number = 'result'; | let c: string = 'result'; | Fix type. | TypeScript |
let val = 22; | let val = 22; | Correct. | JavaScript |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
disp('hello') | disp('hello') | Correct. | MATLAB |
for i=1,20 do print(i) end | for i=1,20 do print(i) end | Correct. | Lua |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
render | render() | Add parentheses. | Swift |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
print 'message' | print('message') | print needs parentheses. | Python |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(83); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(83); | Correct. | Node.js |
const result = 52; result = 57; | let result = 52; result = 57; | Cannot reassign const. | JavaScript |
for (a in items) | for (a of items) | for...in iterates keys. | JavaScript |
local bar = 2 | local bar = 2 | Correct. | Lua |
<br></br> | <br> | Self-closing. | HTML |
function baz() {{ echo 'value'; }} | function baz() {{ echo 'value'; }} | Correct. | PHP |
function baz(count:string){{return count;}} baz(40); | function baz(count:string){{return count;}} baz('world'); | Pass correct type. | TypeScript |
yield z | yield z | Correct yield. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(39); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(39, () => console.log('listening')); | Add callback. | Node.js |
if (index = 80) | if (index == 80) | Use ==. | Scala |
var x int = 'data' | var x string = 'data' | Type mismatch. | Go |
$b = 24; if ($b = 24) {{}} | $b = 24; if ($b == 24) {{}} | Use ==. | PHP |
var x int | var x int | Correct. | Go |
<person age=76> | <person age="76"> | Quote attribute. | XML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
result = 84 | result=84 | No spaces. | Shell |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
const temp; | const temp = 53; | Initialize const. | JavaScript |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let count = 'message' | let count = "message" | Double quotes. | Swift |
if ($count = 36) | if ($count == 36) | Use ==. | Perl |
my @arr = (66,87,16); | my @arr = (66,87,16); | Correct. | Perl |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
print('value') | print('value') | Correct. | R |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
List(75,1,100) | List(75,1,100) | Correct. | Scala |
UPDATE orders SET name='message' WHERE email=53 | UPDATE orders SET name='message' WHERE email=53; | Add semicolon. | SQL |
{{'status':18, 'title' 55}} | {{'status':18, 'title':55}} | Colon missing. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
fn foo() -> i32 {{ 40 }} | fn foo() -> i32 {{ 40 }} | Correct. | Rust |
["hello", 72] | ["hello", 72] | Correct. | JSON |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
if b > 48
print('output') | if b > 48:
print('output') | Colon missing after if. | Python |
SELECT * FROM users WHRE status=73; | SELECT * FROM users WHERE status=73; | Fix WHERE. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
function render() {{
return
{{key:'data'}}
}} | function render() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
[31, 1, 80 | [31, 1, 80] | Close bracket. | Ruby |
class User {{ int item; }}; | class User {{ public: int item; }}; | Make public. | C++ |
let z = 51; z += 1; | let mut z = 51; z += 1; | Need mut to modify. | Rust |
if count = 21 | if count == 21 | Use ==. | Ruby |
'value' + 43 | 'value' + 43.to_s | Convert int. | Ruby |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
[x*x for x in values if x > 60] | [x*x for x in values if x > 60] | Correct list comprehension. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
values(71) | if length(values) >= 71, values(71), end | Check length. | MATLAB |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
switch(val){{ case 42: break; }} | switch(val){{ case 42: break; default: break; }} | Add default case. | Java |
function render(): void {{ return 94; }} | function render(): number {{ return 94; }} | Return type mismatch. | TypeScript |
if ($y = 54) {{}} | if ($y -eq 54) {{}} | Use -eq. | PowerShell |
if result = 60 | if result == 60 | Use ==. | Go |
if c = 3 {{}} | if c == 3 {{}} | Use ==. | Swift |
'data' + 30 | 'data' + str(30) | Can't add int to string. | Python |
let c: i32 = "world"; | let c: &str = "world"; | Type mismatch. | Rust |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
if (item = 72) | if (item == 72) | Use ==. | R |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.